SchemaUpdate 不会删除表或删除列
我正在使用 SchemaUpdate 根据某些配置对数据库进行更改。 添加新表或列时它可以正常工作。 但是,当删除列或删除表时,它不起作用。 映射文件确实反映了这些更改,但 SchemaUpdate 似乎无法识别这一点。 我不想删除表并重新创建它们,因为我希望保留数据。
有谁知道 SchemaUpdate 是否支持此“删除和放置”功能?
谢谢
I am using SchemaUpdate to make changes to the database based on some configuration.
It works fine when new tables or columns are added.
However, it does not work when columns are deleted or tables are dropped.
The mapping file does reflect these changes, but the SchemaUpdate does not seem to recognize this.
I don't want to drop the tables and recreate them, as I want the data to be retained.
Does anyone know if this 'Delete and Drop' functionality is supported by SchemaUpdate?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实并非如此 - SchemaUpdate 只会添加新的表/列。此行为是设计使然 - 您的模型可以(例如)映射到许多系统使用的数据库上,并且它只能使用表/列的子集。在这种情况下,如果 SchemaUpdate 确实删除了这些列和表 - 它会破坏所有其他系统。
请参阅 NHibernate SchemaUpdate 了解替代方案。
It is not - SchemaUpdate will only add new tables/columns. This behavior is by design - your model can (for example) be mapped on a database that is used by many systems, and it could only use a subset of tables/columns. In that case, if SchemaUpdate did drop those columns and tables - it would break all those other systems.
See NHibernate SchemaUpdate for alternatives.