Dev-Notes: Exploring ASP.NET MVC

Code First method build from scratch

  • Make a backup of /Model files and /Migrations and delete xxx_Initial.cs one, delete all files under /Migrations, delete all tables in database
    Alternatively run: Update-Database -TargetMigration $InitialDatabase to roll back to what it was
  • Run enable-migations -Force in PM>
  • Change the /Migrations/configuration.cs file with file below – notepad
  • Run add-migration Initial in PM>
  • Run update-database in PM>
  • Check the database and all the class table in there as well Identity one (ASPNETxxx) and also the /Migration/xxxxxxxx_Initial.cs appearing with ASPNET as well.


  • The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running ‘Add-Migration Initial’ again.



Note: Pageviews – 2,273 (before migrated from Dewalist Blog website on 09/08/2020)