使用 Visual Studio 进行数据库版本控制
在 SO 播客 第 54 集中,Jeff 谈到使用 Visual Studio 保存所有数据库对象到单个文件。 这听起来正是我的团队需要的,以便更好地将数据库架构更改实施到 TFS 中,我向我的领导讲述了这一点。 他认为这是个好主意。
不幸的是,到目前为止我还没有运气让它为我工作。 我的问题之一是我的本地机器上没有安装 SQL Server(部门策略)。 我显然做错了什么。
有人可以给我一个步骤概要或提供一个合适的链接吗?
谢谢!
In the SO podcast episode 54 Jeff talked about using Visual Studio to save all the database objects to individual files. This sounded like just what my team needed to better implement database schema changes into TFS and I told my lead about it. He thinks it's a great idea to.
Unfortunately, so far I've had no luck getting this to work for me. One of my problems is that I don't have SQL Server installed on my local box (dept policy). I'm obviously doing something wrong.
Can someone give me a rundown of the steps or provide a decent link?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
1) 在服务器资源管理器中创建与数据库的连接。
2) 右键单击连接并选择发布到提供商...
3) 接下来,编写脚本到文件,接下来,要发布的数据类型应该是架构(除非您需要一些初始数据),完成。
4) 将脚本添加到项目并签入源代码管理。
1) Create a connection to the database in Server Explorer.
2) Right-click on the connection and select Publish to provider...
3) Next, Script to file, Next, Types of data to publish should be Schema (unless you need some initial data), finish.
4) Add script to the project and check into source control.
他指的是 VS 中支持管理数据库的项目类型,包括(如果设置正确的话)对数据库发布进行版本控制。
查看这篇关于数据库项目的文章VS
He was referring to a project type in VS that supports managing databases, including (if you set it up correctly), versioning your database publishes.
Check out this article on Database Projects in VS
您想要使用 GDR 2。(有时称为 Data Dude)
这允许完全离线的解决方案。 您不需要在计算机上安装 SQL Server 即可实现此功能。 (事实上,GDR 是第一个不关心您是否安装了 SQL Server 的版本。)
我将 GDR 用于我的数据库(由 3 名开发人员和 2 名测试人员组成的团队),它工作得很好!
以下是 GDR 2 版本的链接:
http://blogs.msdn.com/vstsdb/archive/2009/04/21/microsoft-visual-studio-team-system-2008-database-edition-gdr-r2.aspx
并且这是实际位的链接:
http://www.microsoft.com/downloads/details.aspx microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed
基本用途是从现有数据库和服务器导入。 (您可能需要一个服务器项目和 1 个或多个数据库项目)
然后您可以离线进行更改。 当您准备好将更改发送回数据库时,您可以进行部署(请确保首先设置部署选项,因为我认为默认设置是删除数据库并重新部署)。 您还可以在 Visual Studio 中执行数据->架构比较,并将您的项目与数据库进行比较,然后从差异输出中获取更改的脚本。
这需要一些工作,但它确实允许很好的源代码控制,并且一旦掌握了它就很容易。 (我每周两次在夜间构建中自动部署数据库。)
You want to use the GDR 2. (Sometimes called Data Dude)
This allows for a completely offline solution. You don't need to have SQL Server installed on your machine for this to work. (In fact the GDR is the first version that does not care if you have SQL Server installed.)
I use the GDR for my db (a team of 3 devs and 2 testers) and it works GREAT!
Here is a link for the GDR 2 release:
http://blogs.msdn.com/vstsdb/archive/2009/04/21/microsoft-visual-studio-team-system-2008-database-edition-gdr-r2.aspx
And this is a link to the actual bits:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed
The basic use is to import from an existing DB and server. (You will probably want a server project and 1 or more DB Projects)
You can then make your changes off line. When you are ready to send you changes back to the DB you can delploy (make sure you set up your deploy options first as I think the default is to drop the db and re-deploy). You can also do a Data->Schema Compare in Visual Studio and comapre your project to your database then get a script of changes from the diff output.
It takes a bit of work, but it really allows great source control and is easy once you get the hang of it. (I have my db auto deploy in my night time build twice a week.)
如果您要导入现有的数据库架构,那么获取正确的数据库项目很重要。 您可能应该使用“数据库项目\SQL Server 2005 向导”。
Visual Studio 需要数据库连接来创建正在使用的数据库的临时副本。 听起来这就是问题所在。 您的本地机器上有 SQLExpress 吗? 使用它作为部署目标(如果 . 不起作用,服务器名称将为 .\sqlexpress)。
作为替代方案,请获取 Visual Studio 的更新 GDR 2。 据称,它允许人们在不使用 SQL Server 的本地实例来部署数据库的临时工作副本的情况下处理数据库项目。
If you're importing an existing database schema, its important to get the right database project. You should likely be using "Database Projects\SQL Server 2005 Wizard".
Visual Studio requires a database connection it can use to create temporary copies of the databases it is working with. It sounds like this is the issue. Do you have SQLExpress on your local box? Use that as the deployment target (server name would be .\sqlexpress if . does not work).
As an alternative, grab update GDR 2 for Visual Studio. Allegedly, it allows one to work with database projects without using a local instance of sql server to deploy temporary working copies of the database.