VS1010 数据库项目和参考数据脚本
只是想知道处理以下问题的最佳方法......
我想要一个 VS2010 数据库项目来保持开发、集成测试和生产环境中数据库的架构同步。
作为测试和生产环境的一部分,我有很多参考数据需要加载到数据库中。
对于开发和测试,我只需重新创建数据库并使用部署后脚本来加载数据。但是,我实际上无法在生产环境中执行此操作,因为显然它会有实时数据。
那么做到这一点的最佳解决方案是什么?我不认为我可以使用部署后脚本来加载数据库,因为在插入语句的情况下,我需要将每个语句包装在 IF NOT EXISTS... 子句中,并且有 1000 行。
也许最好使用 VS2010 + MSBuild 工具来保持架构最新,然后有一个单独的解决方案来管理数据?
或者有没有纯粹使用 VS2010 + MSBuild 中的工具的解决方案?
Just wondering the best way to handle the following....
I want to have a VS2010 database project to keep the schema of my database in the dev, integration test and production environments in sync.
As part of the test and production environments I have a lot of reference data that needs to be loaded into the database.
For dev and test I can just recreate the database and use Post Deployment scripts to load the data. However, I cant really do this for the production environment as obviously it will have live data on it.
So what is the best solution to do this? I dont think I can use Post Deployment scripts to load the datbase, because in the case of an insert statement I would need to wrap each one inside an IF NOT EXISTS... clause and there are 1000's of rows.
Maybe its best to use the VS2010 + MSBuild tools to keep the schema up to date and then have a seperate solution for managing the data?
Or is there a solution to this that uses purely the tools in VS2010 + MSBuild?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
实时生产环境的最佳解决方案 - 根本不使用自动更新!
使用经过良好测试的手工更新脚本与后端和前端应用程序更新相联系
并且始终有一个好主意新鲜备份
The best solution for live production enviroment - not to use automatic updates at all!
Use very well tested hand made update scripts in touch with your backend and frontend applications update
And there is always a good idea to have a fresh backup
每次都截断并重建参考数据表怎么样?如果存在限制,您可以删除它们并将它们添加回部署后脚本的末尾。这对你有用吗?
或者是否有无法删除生产参考数据的原因?
How about truncating and rebuilding the reference data table each time? If there are constraints you can remove them and add them back at the end of the post-deployment script. Would that work for you?
Or is there a reason why you can't remove production reference data?
对于参考数据,您可以使用一个脚本来处理插入、更新或删除,具体取决于数据是否已在表中。
查看此链接了解更多详细信息(其中还包括一个生成器来帮助您生成脚本)。
For reference data you can have a script that handles an insert, update or delete depending if the data is already in the table or not.
Check out this link for more details (this also includes a generator to help you generate your scripts).
使用填充的数据库生成可在部署后应用的合并语句。
不过,删除 DELETE 子句可能是个好主意。
Use a populated database to generate merge statements that can be applied in Post-Deployment.
It might be a good idea to take out the DELETE clause though.