No initial create with Entity Framework migrations

后端 未结 6 1924
梦如初夏
梦如初夏 2021-01-30 09:13

I\'m trying to get Entity framework migrations working. I\'ve enabled code first migrations, its created a migrations folder, config file and the mig history table, but no initi

6条回答
  •  自闭症患者
    2021-01-30 09:46

    I know this is old, but there is no accepted answer and I had same issue.

    The trick is Enable-Migrations command. As stated here there is a command Enable-Migrations –EnableAutomaticMigrations. What it does it starts migrations exactly where you are.

    If you want the first migration to be creation of database, just run Enable-Migrations (without --EnableAutomaticMigrations).

    And remember to set initializer:

                Database.SetInitializer(new MigrateDatabaseToLatestVersion());
    

提交回复
热议问题