简体   繁体   English

如何防止VS2010数据库项目部署生成丢弃数据库?

[英]How do you prevent a VS2010 Database Project Deployment from generating a drop database?

Suppose you have a database project and you do NOT have "Always re-create database" checked off in your Database.sqldeployment settings. 假设您有一个数据库项目,并且您没有在Database.sqldeployment设置中选中“始终重新创建数据库”。 And suppose you deploy to a server that already has a database by the name of the one you are deploying. 并假设您按照正在部署的名称部署到已具有数据库的服务器。

Under what other circumstances will the database deploy generate a script with a "DROP DATABASE" statement? 在其他情况下数据库部署会生成带有“DROP DATABASE”语句的脚本吗?

If you don't ever, ever, ever want your database to be dropped by the deployment script generated by right clicking your database project and selecting "Deploy", what are some of the steps you can take to prevent this? 如果您从未希望通过右键单击数据库项目并选择“部署”生成的部署脚本来删除数据库,那么您可以采取哪些步骤来防止这种情况发生?

In addition to the "Always re-create database" NOT being checked off, you should also check the Development tab on your database project's Properties page. 除了“永远重新创建数据库”未被检查外,您还应该检查数据库项目的“属性”页面上的“开发”选项卡。 Make sure you define a target connection. 确保定义目标连接。 When you don't define one the project will always and only deploy as-if the target database does not exist. 如果没有定义一个项目,那么项目将始终只作为目标数据库不存在而部署。 This behavior is by design. 此行为是设计使然。 see this link for more details. 有关详细信息,请参阅此链接

My suggestion is to create the connection using Windows Authentication so each user would have access to the extend they are supposed to. 我的建议是使用Windows身份验证创建连接,这样每个用户都可以访问他们应该使用的扩展。

Also please note that you will have to do this for each Deployment Configuration (eg Debug, Release, etc.) 另请注意,您必须为每个部署配置执行此操作(例如,调试,发布等)

I personally set the deploy action to just create a script and run it manually to be on the safe side! 我个人将部署操作设置为只创建一个脚本并手动运行以保证安全!

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

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