Use Codefirst in an existing database, except for the first time you add an entity to do it immediately
Enable-migrations
Add-migration initial-ignorechanges
Update-database
, the others are the same as the new database, and the changes are performed
Add-migration newmodify
Update-database
Note: Generate all the original tables, otherwise it seems that it is not as easy as the database first to add directly.
First, add a new entity class
Because it is code first, some features are added directly, and the fields are for testing only and not complete.
Added a primary foreign key relationship to the post entity (POST).
Accordingly, the post entity needs to be modified:
Second, data migration (can also be set to automatic migration, but for me this rookie manual migration more sense of accomplishment:)
Add-migration AddUser
Update-database
Iv. Post-migration databases
This time is still relatively smooth, money and beauty, one is not less.
EF6 using Codefirst Total review in the original database (Iv. new entity object)