Search code examples
asp.net-mvcvisual-studioentity-framework-6visual-studio-2017

No context type was found in the assembly when running code first migration


While running command enable-migrations in Package Manager Console, got this error:

No context type was found in the assembly 'Vidly'

I am using Visual Studio 2017. How to solve it?


Solution

  • Make sure you have set the Default Project, that is present at the top label with a dropdown in your Package Manager Console. And this project should contains your Entity Framework context.

    You can check this post to find where Default Project drop down located.

    So finaly your code should be like this,

    Enable-Migrations -ProjectName MyContextProjectNameHere -StartUpProjectName MyStartUpProjectNameHere -Verbose
    

    Hope it helps :)