Validate that EF Core ModelSnapshot, migrations, and actual database schema are consistent with each other

会有一股神秘感。 提交于 2019-12-11 08:26:46

问题


I am using EF Core. After "cleverly" merging a couple of source control branches that both introduced migrations, I'm no longer confident that my ModelSnapshot is consistent with either my migrations or my actual database.

Is there some command or function that I can use to validate that the three are consistent with each other (i.e. that the snapshot is a faithful representation of the current database schema and that the migrations, when applied to a newly-created database, will generate that schema)?


回答1:


Here are tools you can use to perform some sanity checks.

  • Add-Migration will show any differences between your current model and the model snapshot
  • Script-Migration will produce a SQL script you can use to create a database from the migrations
  • CreateDatabaseScript will produce a SQL script you can use to create a database from the model
  • SQL Server Data Tools can compare two databases
  • Scaffold-DbContext will create a model that is compatible with a database


来源:https://stackoverflow.com/questions/44851008/validate-that-ef-core-modelsnapshot-migrations-and-actual-database-schema-are

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!