annajust.blogg.se

Ef migration commands
Ef migration commands










As we have 2 DB contexts, we want to have 2 migrations folders as well: one for users and another one for our domains. Without this argument the migrations folder would be created at the root of the project and a directory can only have a single migrations folder. The MigrationsDirectory specifies where the migrations folder will be created for the user management context.

ef migration commands

The simple class name was enough as there’s no other class with the same name, i.e. Run the following command:Įnable-migrations -ContextTypeName UserManagementDbContext -MigrationsDirectory Database\UserManagementMigrations The error message tells us quite clearly that we have to use the ContextTypeName flag to specify the correct context. This is expected as we have 2 Db context types in the project as the message says: CarsDbContext and UserManagementDbContext. To enable migrations for ‘’, use Enable-Migrations -ContextTypeName. More than one context type was found in the assembly ‘Cars.Web’. If all went well then you should get an exception: Open the Package manager console – View, Other windows, Package manager console – and issue the following command to enable migrations: Open the Cars web project we started working on before.

ef migration commands ef migration commands

Previous releases only allowed for one of each. The current version of EF at the time of writing this post allows us to have multiple migration folders and DB contexts. It’s now time to let EF create a database and a table for us where we can store the car objects. We’ve also looked at the absolute basics of EntityFramework in an MVC5 project. In the previous post we’ve created our first DbSet of Cars.












Ef migration commands