Cannot enable migrations for Entity Framework in class library

I just got on board with EF 5 and I use my first code migration tool, but it looks like I am getting an error message when I try to enable migration.

I type Enable-Migrations in the package manager console and then it says

No classes derived from DbContext were found in the current project.
Edit the generated configuration class to indicate the context to enable migration for.
The first start of Migrations is enabled for the MyApp.MvcUI project.

Then it creates the Migrations folder and the Configuration class in my MvcUI project. The fact is that my DbContext lives in a class library project called MyApp.Domain. He should do all this in this project and should not have problems finding my DbContext.

+43
c # entity-framework-5 entity-framework ef-code-first code-first-migrations
Mar 02 2018-12-12T00:
source share
2 answers

Oh wow, it doesn't matter. I'm dumb.

The Nuget Package Manager console has a drop-down menu at the top that says "Project Default:". Make sure you set this for the project you want to run the command with.

Hope this helps someone else escape my awkward mistake.

+101
Mar 02 2018-12-12T00:
source share

There are actually 3 ways to make Nuget commands in a specific project:

  • [Package Manager Console] Set the active project in the drop-down list at the top of the console window.
  • [Package Manager Console] Find the option to specify the project. For some cmdlets I saw -ProjectName, and some use -Project
  • [Solution Explorer] Right-click on the project you want and use the Graphic Package Manager window (Manage NuGet Packages ...).
+11
Mar 02 '12 at 7:15
source share



All Articles