EF migration notes

1.enable-migrations to on migration, while at the root of the migrations to create a new folder Configrations.cs file, you can add initialization data in this file.
Seed Configuration class also includes a method. Test data can be inserted. Seed receiving a database context parameter method, using the new parameters are added to the database entity. Data migration method using AddOrUpdate, if there are previous updates. It is not created.
2.add-migration InitialCreate migrations _InitialCreate.cs folder to create a new file, which is a database manipulation statements, there Up, Dwon method,
3.update-Database perform the migration, and then view the database.

 

Guess you like

Origin www.cnblogs.com/hello147/p/11404940.html