日期:2014-05-16 浏览次数:20385 次
SQL SERVER DATABASE PROJECT能够从Visual Studio中创建的脚本来创建本地的数据库。比如说,别人给了你一个已经搭建好的Solution, 里边用到了SQL Server数据库。你现在想在本地跑这个程序,就需要在本地创建这个数据库实例。如果使用SQL语句脚本的话,也可以。但是还是需要从别人的已经建好了数据库中往外生成SQL语句,生成后你再在你的本地机器上执行这个SQL文件,而且有时候还会有一些版本上的细微的区别。如果使用Database Project的话,只需要在solution中添加database项目,以后无论谁想在本地搭建数据库环境,只需要把这些脚本发布到本地数据库中就可以。
具体步骤如下:
You can reverse engineer a database project from an existing database, or create a new project from scratch. This article will focus on how to create one from scratch. Open Visual Studio and either create a new solution or open an existing one to which this new database should be a part of.
Select the Other Languages, SQL Server template group on the left. Then choose the SQL Server Database Project type. Enter a project name and press OK. I usually pick a project name matching the class library that will contain the business layer or data layer that will interact with this database, and then append Database to the end of that name. It may make more sense to also put SQL in the name; just in case you use another type of database in the future.
You should check out the project properties and see what options are available. On the main Project Settings tab page, there