如何在Visual Studio 2010数据库项目中开发TSQL

时间:2023-01-16 15:01:05

Silly sounding question, I know... Let me lay some groundwork first.

愚蠢的问题,我知道......让我先做一些基础工作。

I have successfully created a database project comprised of the hundreds of tables, stored procedures, indexes, et.al. that make up our production database.

我已经成功创建了一个由数百个表,存储过程,索引等组成的数据库项目。构成我们的生产数据库。

I have successfully added the solution to source control (TFS).

我已成功将解决方案添加到源代码管理(TFS)。

I have made a change (as a test) to some of the objects and generated a deployment script, and the whole system is very impressive, I must say. But it seems the strength of VS 2010, from a DB perspective is deployment, and not necessarily development.

我必须说,我对一些对象进行了更改(作为测试)并生成了部署脚本,整个系统非常令人印象深刻。但似乎VS 2010的实力,从数据库的角度来看是部署,而不一定是开发。

I am totally baffled on the day-to-day workflow involved in database/TSQL development using Visual Studio. Let's suppose I need to add a few columns to a table, and modify related stored procedures to return/update this data for these columns.

我对使用Visual Studio进行数据库/ TSQL开发所涉及的日常工作流程感到困惑。假设我需要向表中添加几列,并修改相关的存储过程以返回/更新这些列的数据。

While it's easy enough to modify all the scripts in my database model, I'd like to be able to isolate them against a dev database where I can do some testing... But it's as simple as not being to update a proc if it exists without manually changing the script to an ALTER (or adding DROP code prior to the CREATE). Having to do this once or twice is a non-issue, but in a real dev environment, we do this all day long.

虽然很容易修改我的数据库模型中的所有脚本,但我希望能够将它们与开发数据库隔离开来,我可以在那里进行一些测试...但是它就像没有更新proc一样简单存在而无需手动将脚本更改为ALTER(或在CREATE之前添加DROP代码)。必须这样做一两次是没有问题的,但在真正的开发环境中,我们整天都这样做。

Perhaps the answer is to perform frequent deployments to the dev server, as I debug and make changes to procs, for instance? Quite a bit of overhead; I could execute the necessary scripts manually in a few seconds, building and deploying takes a few minutes. Plus, if three of us are deploying different changes to a dev DB, wouldn't we overwrite each other's modifications?

也许答案是经常部署到开发服务器,例如我调试并对proc进行更改?相当多的开销;我可以在几秒钟内手动执行必要的脚本,构建和部署需要几分钟。另外,如果我们三个人正在为dev DB部署不同的更改,我们是否不会覆盖彼此的修改?

Sorry to be so longwinded, but I can't help but think I am missing something simple here.

很抱歉这么长,但我不禁想到我在这里错过了一些简单的东西。

Are there any books/tutorials/webinars that showcase this type of approach to actual development?

是否有任何书籍/教程/网络研讨会展示了这种实际开发方法?

1 个解决方案

#1


6  

I think you've hit the nail on the head. In order to test your modified stored procedures, you have to go through the deployment step to update your database. That's the drawback of the offline development model.

我觉得你已经敲了敲头。为了测试已修改的存储过程,您必须完成部署步骤以更新数据库。这是离线开发模型的缺点。

Here at Red Gate we've had numerous requests to make SQL Source Control support the Database Project, which would allow developers to benefit from the 'online' development model whilst still benefiting from the Database Project features.

在Red Gate,我们有很多要求使SQL Source Control支持数据库项目,这将允许开发人员从“在线”开发模型中受益,同时仍然受益于数据库项目功能。

[EDIT] We've added 'Beta' support for the database project in SQL Source Control, which allows connected SSMS development against the database project format. Simple link to the folder with eh .sqlproj file from SQL Source Control and start developing! [/EDIT]

[编辑]我们在SQL源代码管理中为数据库项目添加了“Beta”支持,它允许针对数据库项目格式进行连接的SSMS开发。使用SQL Source Control中的eh .sqlproj文件轻松链接到该文件夹​​并开始开发! [/编辑]

In the meantime, you'll have to keep deploying to dev on a regular basis!

与此同时,您必须定期继续部署到开发人员!

An alternative is to develop on a real database, and use the Schema Compare feature to synchronize back to your Database Project. Schema Compare is available in the Premium and Ultimate editions of Visual Studio.

另一种方法是在真实数据库上开发,并使用Schema Compare功能同步回数据库项目。 Schema Compare可在Visual Studio的Premium和Ultimate版本中使用。

David Atkinson Product Manager Red Gate Software

David Atkinson产品经理Red Gate Software

#1


6  

I think you've hit the nail on the head. In order to test your modified stored procedures, you have to go through the deployment step to update your database. That's the drawback of the offline development model.

我觉得你已经敲了敲头。为了测试已修改的存储过程,您必须完成部署步骤以更新数据库。这是离线开发模型的缺点。

Here at Red Gate we've had numerous requests to make SQL Source Control support the Database Project, which would allow developers to benefit from the 'online' development model whilst still benefiting from the Database Project features.

在Red Gate,我们有很多要求使SQL Source Control支持数据库项目,这将允许开发人员从“在线”开发模型中受益,同时仍然受益于数据库项目功能。

[EDIT] We've added 'Beta' support for the database project in SQL Source Control, which allows connected SSMS development against the database project format. Simple link to the folder with eh .sqlproj file from SQL Source Control and start developing! [/EDIT]

[编辑]我们在SQL源代码管理中为数据库项目添加了“Beta”支持,它允许针对数据库项目格式进行连接的SSMS开发。使用SQL Source Control中的eh .sqlproj文件轻松链接到该文件夹​​并开始开发! [/编辑]

In the meantime, you'll have to keep deploying to dev on a regular basis!

与此同时,您必须定期继续部署到开发人员!

An alternative is to develop on a real database, and use the Schema Compare feature to synchronize back to your Database Project. Schema Compare is available in the Premium and Ultimate editions of Visual Studio.

另一种方法是在真实数据库上开发,并使用Schema Compare功能同步回数据库项目。 Schema Compare可在Visual Studio的Premium和Ultimate版本中使用。

David Atkinson Product Manager Red Gate Software

David Atkinson产品经理Red Gate Software