[英]Sharing database project in TFS
I created a database project as part of my solution with scripts for my tables. 作为解决方案的一部分,我使用表脚本创建了一个数据库项目。 I'm using database first, so all I do is run the project to build/deploy my tables to the database. 我首先使用数据库,所以我要做的就是运行项目以将表构建/部署到数据库。
I'm working with a few others so I checked the SQL project into TFS. 我正在和其他一些人一起工作,所以我将SQL项目签入了TFS。
So the other people can get the solution, run the SQL project and generate the local database for themselves. 这样其他人可以获取解决方案,运行SQL项目并为自己生成本地数据库。
The problem is, it might generate them under another local instance. 问题是,它可能在另一个本地实例下生成它们。 For instance, on my home computer, it generated it under (localdb)\\Projects, but on my laptop, under (localdb)\\ProjectsV12. 例如,在我的家用计算机上,它是在(localdb)\\ Projects下生成的,而在我的笔记本电脑上是(localdb)\\ ProjectsV12下。
This breaks the connection strings (which of course can be fixed). 这会破坏连接字符串(当然可以固定)。 But this leaves me wondering, is there a better way to develop the SQL project collaboratively? 但这让我想知道,是否有更好的方法来协作开发SQL项目?
If you have the SQL code under source control then everyone can open that solution to edit/create copies of the database. 如果您具有源代码控制下的SQL代码,那么每个人都可以打开该解决方案来编辑/创建数据库副本。 Ideally you have an automated process but that does not work for local dev. 理想情况下,您有一个自动化流程,但不适用于本地开发人员。
Since sharing code is a bad idea and you have expressed that the database is used by more than one solution I would consider packaging and distributing it. 由于共享代码是一个坏主意,并且您已经表示数据库已被多个解决方案使用,因此我将考虑打包和分发它。
If you create a SSDT database project you can compile your database into a package that can upgrade any instance. 如果创建SSDT数据库项目,则可以将数据库编译为可以升级任何实例的软件包。 You can then share that .dacpac output easily. 然后,您可以轻松共享该.dacpac输出。
You might even what to share it with Nuget so that each dependency is automatically updated. 您甚至可以与Nuget共享它,以便每个依赖关系自动更新。
You can setup a SQL alias name to standardize the connection string across developer machines. 您可以设置SQL别名,以标准化开发人员计算机之间的连接字符串。
Alias .\\SQLEXPRESS to (LocalDB)\\MSSQLLocalDB 别名。\\ SQLEXPRESS到(LocalDB)\\ MSSQLLocalDB
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.