如何在源代码控制的 Web 应用程序中自动检出数据库文件?

发布于 2024-08-29 04:53:14 字数 269 浏览 1 评论 0原文

我正在开发一个 ASP.NET Web 应用程序,我们是一个小团队(4 名学生),我们无法访问专用服务器来托管数据库实例。因此,对于这个 Web 应用程序,我们决定将数据库文件放在 App_Data 文件夹中。

问题是我们的项目是在 TFS 上进行源代码控制的,因此每次您打开解决方案并尝试启动 Web 应用程序时,我们都会收到一条错误消息,指出数据库是只读的。这是合乎逻辑的,因为数据库文件不会自动签出。

是否有解决方法可以避免每次打开解决方案时手动检出数据库文件?

谢谢。

I am working on an ASP.NET web application, we are a small team (4 students) and we do not have access to a dedicated server to host the database instance. So for this web application we decided just to put the database file in the App_Data folder.

The problem is that our project is source controled on TFS, so every time you open the solution and try to launch the web application, we get an expcetion saying that database is read-only. That is logical because the databse file is not automatically checked-out.

Is there a workaround to avoid a manual check-out of the database file everytime we open the solution ?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

十级心震 2024-09-05 04:53:14

切勿检入 MDF 文件。您应该使用部署脚本来开发项目,该脚本创建您需要的表和其他数据库对象。切勿直接从 VS Server Explorer 修改 MDF。使用基于版本的数据库架构方法

我知道你会说“但是很难”,但是相信我,VS 向导指导你的替代方案要糟糕得多。不仅从团队开发的角度来看,而且从部署的角度来看也是如此。部署站点的 v1 后,您将进行更改并希望部署 v1.1 或 v2。每次,您都会面临同样的困境:您有 4 个 MDF 文件,每个团队成员登记一个,部署站点上一个,而且根本没有办法对齐架构。您最终会要求使用 SQL Compare 等 SQL diff 工具,但它们要花费大量资金,而且在维护 SQL 模式方面远非完美。

此外,将脚本作为数据库源也将与所有其他源代码控制功能很好地结合起来,例如跟踪谁更改了什么以及何时更改。

Never check in MDF files. You should develop your project with a deployment script that creates the tables and other database objects you need. Never modify the MDF directly from VS Server Explorer. Use a version based approach to database schema.

I know you'll say 'but is hard', but trust me, the alternative which VS wizards guide you is far worse. Not only from a team development point of view, but from deployment point of view too. After you deploy v1 of you site, you'll make changes and want to deploy v1.1 or v2. Each time, you'll face the same dilemma: you have 4 MDF files, one on each team member enlistment, and 1 on the deployed site, and there is simply no way to align the schemas. You'll end up asking for SQL diff tools like SQL Compare, but they cost a tonne of moneys and they're far from perfect when it comes to maintaining a SQL schema.

Besides, having scripts as your database source will also align well with all the other source control goodies, like tracking down who changed what and when.

冷︶言冷语的世界 2024-09-05 04:53:14

如果您能够安装 Visual Studio 的“Visual Studio Team System Database Edition”附加组件(以前称为“Visual Studio Team Edition for Database Professionals”,以前称为“DBPro”),则可以将当前数据库导入到 Visual Studio 数据库中项目,它可以是整个 VS 解决方案的一部分。

然后,您可以在 Visual Studio 中管理架构对象(表、存储过程、权限等),并将数据库架构与 TFS 很好地集成。

它还允许您将 VS 项目中的架构部署到数据库服务器,自动处理修改而不会导致数据丢失(如果数据丢失则失败)。

VS 2008 的附加组件位于:
http://www.microsoft.com/downloads/details.aspx microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&displaylang=en

If you are able to install "Visual Studio Team System Database Edition" add-on for Visual Studio (previously called "Visual Studio Team Edition for Database Professionals", previously called "DBPro") you can import your current database into a Visual Studio Database project, which can be part of your overall VS Solution.

This then allows you to manage schema objects (tables, stored procs, permissions etc.) in Visual Studio and integrates your database schema nicely with TFS.

It also allows you to deploy the schema in your VS Project to the database server, automatically handling modifications without causing data loss (or failing if data would be lost).

The add-on for VS 2008 is located at:
http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&displaylang=en

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文