No initial create with Entity Framework migrations

后端 未结 6 1855
梦如初夏
梦如初夏 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:58

    "Initial Create" is NOT created automatically! You need to create that yourself. Some tutorials of EF are confusing and I had the same misunderstanding as you.

    What you need to do:

    -Add-Migration InitialModel
    

    If you already have created your database tables and domain model, then:

    -Add-Migration InitialModel -IgnoreChanges
    

    From this point, your code will be in sync with database. Anytime you change the code, you can use Add-Migration to add the changes to your database.

提交回复
热议问题