Reputation: 11
I have two models, one I created in Microsoft SQL Server.... and one I am attempting to manage user roles etc for the application.
I used an approach that considers the ApplicatonDBContext
for registering, deleting users etc.
I have added the code in the controller and in the AccountViewModels
in order to create my views.
I now need to enable migrations to update the database, but an error in the Package Manager Console appears:
More than one context type was found in the assembly 'Greenwich_Placement'. To enable migrations for 'Greenwich_Placement.Models.ApplicationDbContext', use Enable-Migrations -ContextTypeName Greenwich_Placement.Models.ApplicationDbContext. To enable migrations for 'Greenwich_Placement.Models.PlacementEntities', use Enable-Migrations -ContextTypeName Greenwich_Placement.Models.PlacementEntities.
So I use the command:
use Enable-Migrations -ContextTypeName Greenwich_Placement.Models.ApplicationDbContext
This error now appears:
The context type 'Greenwich_Placement.Models.ApplicationDbContext.' was not found in the assembly 'Greenwich_Placement'.
Thanks
Upvotes: 1
Views: 924
Reputation: 71
I ran into the same problem today. When I enabled migrations, I copied from the output given in the "More than one context" error:
PM> Enable-Migrations -ContextTypeName MyPoject.Models.ApplicationDbContext.
and naturally, received the error
The context type 'MyPoject.Models.ApplicationDbContext.' was not found in the assembly 'MyPoject'.
Then I realized that there was a period at the end of ApplicationDbContext. When I removed it the migration worked fine:
PM> Enable-Migrations -ContextTypeName MyPoject.Models.ApplicationDbContext
Hope your issue is as simple/stupid as mine was!
Upvotes: 2