Furkan R
Furkan R

Reputation: 31

ASP.NET Mvc Project EF Code First Enable Migrations Error

I am working PluralSight Video Tutorials on ASP.NET MVC. And i couldn't enable migrations on package console..

when i wrote enable-migrations, i am receiving this error;

More than one context type was found in the assembly 'eManager.Web'. To enable migrations for eManager.Web.Infrastructure.DepartmentDb, use Enable-Migrations -ContextTypeName eManager.Web.Infrastructure.DepartmentDb. To enable migrations for eManager.Web.Models.UsersContext, use Enable-Migrations -ContextTypeName eManager.Web.Models.UsersContext.

when i wrote Enable-Migrations -ContextTypeName eManager.Web.Infrastructure.DepartmentDb., i am receiving this error;

The context type 'eManager.Web.Infrastructure.DepartmentDb.' was not found in the assembly 'eManager.Web'.

Thanks for your help.

Upvotes: 1

Views: 2429

Answers (3)

Jemil Oyebisi
Jemil Oyebisi

Reputation: 653

The solution to this problem is simple, just remove the dot (.) at the end of this statement "Enable-Migrations -ContextTypeName eManager.Web.Infrastructure.DepartmentDb." and run the package manager console again, the migration should be enabled.

Upvotes: 0

Anas Ghanem
Anas Ghanem

Reputation: 127

The solution for the mentioned error "The context type .... was not found" is to select the correct project that holds the context type before running the enable-migration command. You can choose the correct project from the "default project" drop down at the top of Nuget manager tool window.

Upvotes: 1

Gaz Winter
Gaz Winter

Reputation: 2989

I strongly suspect that your issue is similar to the one in this question:

How to Enable Migration to update my database in MVC4?

Check the selected answer and see if that helps with your issue.

Upvotes: 2

Related Questions