Reputation: 3711
I have ASP.NET MVC4 app with Entity Framework Code First approach. I've moved my DbContext inheritor to separate Model project recently (I've copied connection string from web.config to the app.config).
Now when I'm trying to run my app I've got error that my database should be created directly through Code First or Migrations. First way is not suitable for me because I have remote DB server (I've created it through hoster's control panel).
But when I'm trying to enable Migrations I've got error that No context type was found in the assembly 'MyProject'
. This is obviously happen because my DbContext inheritor not placed in the start project.
So how can I indicate to look context class in separate project?
By the way, I have DropCreateDatabaseIfModelChanges<>
initializer for my DbContext inheritor.
Upvotes: 1
Views: 1793
Reputation: 28376
In the Package Manager Console, if you run Get-Help Enable-Migrations
, it will show you all of the advanced options. Included in those are:
When you're using Add-Migration
it should support the same options.
You can also change the Package Manager Console's Default Project dropdown to run against your model project by default.
Upvotes: 2
Reputation: 4742
If you are using Package Manager Console you can choose a default project where entity framework will search your DbContext
.
Upvotes: 2