0

MVC 4 프로젝트 (Company.Project.WebUI), 내 모든 모델 클래스 (Company.Project.Data) 프로젝트 및 DAL (Company.Project. 서비스).Entity Framework 코드 첫 마이그레이션에서 다른 DLL

코드 첫 마이그레이션으로 어떻게 관리 할 수 ​​있습니까? 나는 다음과 같은 오류를 받고 있어요

나는 명령 Add-Migration Init 쓸 때 : I 명령 Add-Migration -StartUpProjectName "Company.Project.Services" Init을 쓸 때

`

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. 
    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) 
    at System.Reflection.RuntimeModule.GetTypes() 
    at System.Reflection.Assembly.GetTypes() 
    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration() 
    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator() 
    at System.Data.Entity.Migrations.Design.ToolingFacade.GetPendingMigrationsRunner.RunCore() 
    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run() 

`

나는 또한 오류가 발생합니다을

`

System.IO.FileNotFoundException: Could not load file or assembly 'Company.Project.WebUI' or one of its dependencies. The system cannot find the file specified. 
File name: 'Company.Project.WebUI' 
    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) 
    at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) 
    at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) 
    at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) 
    at System.Reflection.Assembly.Load(String assemblyString) 
    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration() 
    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator() 
    at System.Data.Entity.Migrations.Design.ToolingFacade.GetPendingMigrationsRunner.RunCore() 
    at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run() 

다른 사람이 EF 코드 첫 번째 마이그레이션을 사용하는 가장 좋은 방법은 무엇입니까?

답변

0

왜 그런지 모르지만 EF는 DAL 프로젝트가 Visual Studio의 시작 프로젝트로 설정되기를 원합니다. 방금 같은 오류가 있었고 문제가 해결되었습니다.

솔루션 탐색기에서 : DAL 프로젝트를 마우스 오른쪽 단추로 클릭하고 "시작 프로젝트로 설정"을 선택하십시오.