클래스 라이브러리에서 엔티티 프레임 워크에 대한 마이그레이션을 활성화 할 수 없습니다
-
15-11-2019 - |
문제
방금 EF 5와 함께 보드를 타고 코드 첫 번째 마이그레이션 도구를 사용하고 있지만 마이그레이션을 활성화하려고 할 때 오류가 발생하는 것 같습니다.
i Enable-Migrations
를 패키지 관리자 콘솔에 입력 한 다음 라고합니다.
현재 프로젝트에서 발견 된 dbContext에서 파생 된 클래스는 없습니다.
생성 된 구성 클래스를 편집하여 마이그레이션을 사용하도록 컨텍스트를 지정하십시오.
프로젝트 myApp.mvcui를위한 코드 첫 번째 마이그레이션을 사용하도록 설정합니다.MVCUI 프로젝트에 마이그레이션 폴더와 구성 클래스를 만듭니다.내 dbContext는 myApp.Domain이라는 클래스 라이브러리 프로젝트에서 살기입니다.해당 프로젝트에서 모든 일을해야하며 내 dbContext를 찾는 데 아무런 문제가 없어야합니다.
해결책
Oh wow, nevermind. I'm dumb.
In the Nuget package manager console there is a dropdown menu at the top labeled "Default Project:". Make sure you set that to the project you want to run the command against.
Hopefully this helps someone else avoid my embarrassing mistake.
다른 팁
There are actually 3 ways to make Nuget commands run in a specific project:
- [Package Manager Console] Set the active project in the dropdown at the top of the console toolwindow
- [Package Manager Console] Look for a parameter to specify the project. For some cmdlets I've seen -ProjectName and some use -Project
- [Solution Explorer] Right-click the project you want, and use the graphical package manager window (Manage NuGet Packages...).