Visual Studio 数据库项目和 SQL Server 管理
我喜欢使用 SQL Server Management Studio 来更改和更新我的数据库。它比我自己写改变更容易、更快、更安全。
我正在研究对数据库使用某种版本控制,并阅读了有关在 Visual Studio 2010 中使用 SQL Server 数据库项目的信息。
我编写了现有数据库的脚本并将其导入到新的 SQL Server 数据库项目中。现在,据我所知,没有 GUI 可以编辑数据库;如果不亲自编写脚本,我无法添加列、更改数据类型或编辑现有数据。例如,在 SQL Server Management Studio 中,我可以右键单击表名称并选择“设计”,然后从那里添加/编辑列、更改数据类型等。
虽然 Visual Studio 的数据库项目具有 SQL Management Studio 所没有的一些功能,但我认为没有“表设计器”我就无法生存。
VS 的数据库项目中是否内置了一个我没有看到的表设计器?
I enjoy using SQL Server Management Studio for change and updating my database. Its easier, faster, and safer than writing changes myself.
I was looking into using some sort of version control for databases and read about using a SQL Server Database Project in Visual Studio 2010.
I scripted out an existing database and imported it into a new SQL Server Database Project. Now, from what I can tell, there is no GUI to edit the database; I can't add columns, change datatypes, or edit existing data without scripting it myself. For instance, in SQL Server Management Studio I can right click on a table-name and select "Design" and then add/edit columns, change datatypes, etc from there.
While Visual Studio's Database Projects has some features SQL Management Studio does not have I don't think I can live without a "table designer".
Is there a table designer built into VS's Database Project I'm just not seeing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不,没有表格设计师。
如果您开始考虑对数据库进行版本控制,那么您还应该考虑编写实际的 SQL 来实现数据库对象。这就是数据库项目迫使你失望的路线。如果您无法为数据库更改编写 SQL,那么您如何能够查看和欣赏表 6 个月前的情况与当前项目中的情况之间的差异?
No, there's no table designer.
If you're starting to think about version controlling your database, you ought also to be thinking about writing actual SQL to implement your database objects. That's the route that the Database Projects force you down. If you can't write the SQL for your database changes, how are you going to be able to review and appreciate a diff between how a table was 6 months ago, and how it currently is in your project?
我已经使用 VS2008 数据库项目进行版本控制大约 10 个月了。我仍然时不时地使用表格设计器,它是一个快速且简单的工具。我相信您的大部分问题都围绕工作流程,因为我发现这是版本控制环境中开发最具挑战性的部分。我建议继续在 Management Studio 中设计对象,或者以您喜欢的方式设计对象,然后创建脚本并将该脚本导入到数据库项目中。执行此操作时会出现一些怪癖,即使您在环境中执行更改,也始终需要编写创建语句的脚本。此外,您还需要删除数据库的所有 USE 语句,因为导入脚本的上下文始终位于要导入到的项目中。
我们发现,促进代码部署的成功工作流程是拥有一个生产分支,该分支分支到主分支(开发分支),然后进行测试。所有新的开发都在 Main 中完成,并根据需要通过变更集合并到其他环境中。
您可以通过右键单击解决方案并单击导入脚本从开发环境导入脚本。我建议您检查所有选项以覆盖现有对象、导入扩展属性和导入权限。
I've been using VS2008 Database Projects for about 10 months now for our version control. Every now and then I do still use the table designer, it is a quick and easy tool. I believe the majority of your question centers around workflow as this is what I found to be the most challenging part about development in a version controlled environment. I would recommend continuing to design your objects in Management Studio or however you're comfortable and then do a create script and import that script into your Database project. There are some quirks when doing this, you'll need to always script the create statement even if you're performing an alter in your environment. As well you'll need to remove any USE statements for your database as the context in which you're importing your scripts will always be in the project you're importing to.
We have found that a successful workflow for us to facilitate code deployment is to have a production branch which is branched to a Main (development branch) and then to test. All new development is done in Main and merged by changeset to each other environment as required.
You can import your scripts from your development environment by right clicking in the solution and clicking import scripts. I recommend that you check all the options to overwrite objects that exist, import extended properties and import permissions.
使用 SSMS 的 GUI 工具更改数据库架构后,您可以使用数据库项目的架构比较工具来更新项目文件(将源设置为您的数据库,将目标设置为您的项目)。这样您就可以继续使用 GUI 工具来管理架构,并且数据库项目将管理版本控制。
After changing your DB schema using SSMS's GUI tool, you can use Database project's Schema Compare tool to update your project files (set the source to be your database and target to be your project). This way you can keep using GUI tool to manage the schema and the database project will manage the versioning.
Visual Studio 2010 数据库项目中没有可视表设计器。但是,关于数据库的版本控制,有一个解决方法 - 您可以将 SQL Server Management Studio 与 Red Gate 的 SQL 源代码控制。
虽然要花一些钱,但绝对值得。
There is no visual table designer in Visual Studio 2010 Database Project. But, concerning version control for databases, there is a workaround - you can use SQL Server Management Studio together with Red Gate's SQL Source Control.
It costs some money but definitely is worth it.