使用 Visual Studio 2010 Professional 进行版本控制中的数据库
我已将 SQL Server 2008
数据库项目添加到我的 Visual Studio 2010 Professional Edition
解决方案中,希望它可以让我将数据库包含在版本控制中。
我可以将每个数据库对象的架构文件提交到版本控制中,但是这些架构文件将所有脚本对象作为创建而不是更改,因此不利于大学获取我的更改并更新他们的数据库。
这是让我的数据库进入源代码控制的好方法吗?
实际使用它来将数据库更新到给定版本而不丢失与删除和重新相关的所有数据的工作流程是什么? -创建所有表?
更新:在高级版和旗舰版上,有一个架构比较工具可以使这变得简单。 Professional 上不存在这一点。有没有简单的手动解决方法?
I've added a SQL Server 2008
database project to my Visual Studio 2010 Professional Edition
solution in the hope that it might allow me to include my database in version control.
I can commit the schema files for each database object into version control, however these schema files all script objects as create rather than alter, so are not good for colleges getting my changes and updating their databases.
Is this a good way to get my database into source control?
And what would the workflow be for actually using it to update databases to a given revision without losing all the data associated with dropping and re-creating all the tables?
Update: on Premium and Ultimate versions, there is a schema compare tool which makes this easy. This does not exist on Professional. Is there any straightforward manual workaround?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定您是否可以在 VS 2010 Professional 中执行此操作,但在 VS 2010 Premium 中,您可以在项目和数据库之间进行架构比较(数据 -> 架构比较 -> 新架构比较),并更新更改在任一方向。
当从项目转到数据库时,VS 会生成一个脚本,在删除现有数据之前将现有数据复制到临时表中。
I'm not sure if you can do this in VS 2010 Professional, but in VS 2010 Premium, you can do a schema comparison (Data -> Schema Compare -> New Schema Comparison) between your project and database, and update changes in either direction.
When going from project to database, VS generates a script that copies existing data into a temporary table before dropping the existing one.
数据库项目有一个部署步骤(存在于我的 VS2010 Professional 副本中),它将生成一个包含 sql 对象的 sql 脚本。
这里的关键是,如果您右键单击项目、属性,转到部署并将目标数据库设置更改为特定数据库,那么当您部署时,它将为该特定数据库生成一个更改脚本,以便它与项目中的对象相匹配(并且理论上保留现有数据等)。
你可以让它生成一个sql脚本,或者直接更新数据库。生成脚本可能是一个更好的主意:)
The database project has a deploy step (which is present in my Professional copy of VS2010) that will generate a sql script with your sql objects in it.
The key thing here is if you r-click the project, properties, goto deploy and change target database settings to a specific database, when you deploy it will generate a change script for that specific database so it matches the objects in the project (and in theory keep existing data etc).
You can get it to either generate a sql script, or directly update the database. Generating a script is probably a better idea :)