How can I disable code first migrations

后端 未结 5 1641
醉话见心
醉话见心 2020-11-30 23:05

I have a code-first entity model in EF5. But I want to manage the database changes manually -- I do not want EF to modify my existing database and all its data. But when I m

5条回答
  •  不思量自难忘°
    2020-11-30 23:20

    If you want to completely turn off migrations:

    https://stackoverflow.com/a/9709407/141172

    However, I found it better to keep code first migrations enabled, but use the -Script option to have EF create a DB change script for me that I can apply to each database (development, QA, Production) manually:

    Update-Database -Script -ProjectName MyProject -StartupProjectName MyProject
    

    That way EF will create the change script for me, and I still have full control over changes being applied. I version the change scripts like any other source code.

提交回复
热议问题