This post thows up a glimpse on the basic commads syntax and usage serving as a quick reference when ever you are struck out for pretty basic thing. Let’s get started.
Want to enable Migrations in your Project ?
This command add Migrations Folder to our project which has two files
1.The Configuration class
2.An InitialCreate migration
Changed something in datamodel and you want EF to scaffold chages for you?
Want to reflect the changes in the Database?
-verbose ,To see the sql behind the update.
Downgrade the database changes?
In TargetMigration, specify the name of the migration upto which you wish to downgrade the changes.
Downgrades the changes to the Initial Database state.
Update-Database-Script-SourceMigration:$InitialDatabase-TargetMigration: writes the migration to an sql file rather than migrations being applied.SourceMigration and TargetMigrations vary in between the migrations present.Migration file Name is prefixed with timestamp to help ordering of migrations
Multiple Models Sharing the _MigrationsHistory Table
Starting with EF6, the Configuration class includes a ContextKey property. This acts as a unique identifier for each Code First model. A corresponding column in the __MigrationsHistory table allows entries from multiple models to share the table. By default, this property is set to the fully qualified name of your context.