如何确保流畅的 NHibernate 映射和迁移同步?
我使用 Migrator Dot Net 来版本化我的数据库架构,并使用 Fluent NHibernate 将模型映射到架构。
是否有一种好的(阅读:自动化)方法来比较运行迁移生成的模式与 NH 模式导出生成的模式,以确保表定义、键、索引等同步?
我唯一能想到的就是导出两个模式,然后使用一些未知的(如果你知道一个好的库就回答!)将它们编写成脚本,然后比较脚本字符串。
有更好的办法吗?
编辑:澄清一下,我不仅想验证表、列和列类型,还想验证索引和外键。
I use Migrator Dot Net to version my database schema, and Fluent NHibernate to Map models to the schema.
Is there a good (read: automated) way to compare the schema generated by running migrations with the schema generated by the NH schema export to ensure that table definitions, keys, indices etc are in sync?
The only thing I can think of would be to export both schemas, then use some unknown (answer if you know a good one!) library to script them out, then compare script strings.
Is there a better way?
Edit: To Clarify, I would like to verify not only tables, columns, and column types, but also indices and foreign keys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NHibernate 中有一个模式验证器:
There is a schema validator in NHibernate:
我认为检查 FNH 生成的映射和您的数据库架构是否同步就足够了。
为此,您可以使用这个简单的测试
I think that it would suffice to check that the mappings generated by FNH and your DB schema are in sync.
for that you can use this simple test