No context type was found in the assembly while using entity framework 6 code-first approach

.net asp.net-mvc c# ef-migrations entity-framework-6

Question

I am using Visual Studio 2017 and Entity Framework 6 "Vidly" is the name of my project and solution. How to fix this migration issue? Please help Below are the screen shot of package manager console and solution explorer.

I have tried the following to fix the issue, But couldn't fix the issue

1) the Package Manager Console there's a "Default project" dropdown. You need to set this to the project that contains your EF context.

2) Enable-Migrations -ProjectName Vidly -StartUpProjectName Vidly -Verbose

Package Manager Console - Error

Solution Explorer


EDIT

Try to create a new project, just to check what we need. Ok so you go file> new> project, under visual c# menu new asp.net web application, choose any name for the project, this is just to check what it missing in our project. click ok, select MVC in the left side, and in the right side we can see a change authentication button, and under that button says, authentication: No authentication, click there and select individual user accounts. Click ok and that option, automatically install entity and identity. That is the problem.

1
0
10/30/2017 3:10:41 PM

Accepted Answer

I eventually found the answer in this question. Basically, in the Package Manager Console there's a "Default project" dropdown. You need to set this to the project that contains your EF context.

83
5/23/2017 11:54:29 AM

Popular Answer

I found similar post: Enable Migrations with Context in Separate Assembly?

Example:

enable-migrations -ContextProjectName MyProject.DBContexts -contexttypename MyProject.DBContexts.MyContextName -Verbose


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow