简体   繁体   English

数据库模式版本控制

[英]Database schema versioning

At the moment I am using code first entity.目前我正在使用代码优先实体。 I have added a backup / restore feature to my application which basically does a full database backup / restore using T-SQL.我在我的应用程序中添加了备份/恢复功能,它基本上使用 T-SQL 执行完整的数据库备份/恢复。

To avoid someone trying to restore a backup for an older version with different schema, I want to restrict this feature so the restore will only be applied if the schema of the backup file is the same.为避免有人尝试为具有不同架构的旧版本恢复备份,我想限制此功能,以便仅在备份文件的架构相同时才应用恢复。

What is a good way of dealing with this?什么是处理这个问题的好方法? First thing that comes into mind is adding a version to the database.首先想到的是向数据库添加一个版本。 Is there a nice way to add versioning?有没有好的方法来添加版本控制?

Database schema changes are stored in__MigrationsHistory (for CodeFirst).数据库架构更改存储在 __MigrationsHistory(用于 CodeFirst)中。 It's EF internal versioning mechanism.这是 EF 内部版本控制机制。 Use it.用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM