英文:
LocalDB Help using SQL Server 2008 R2
问题 {#heading}
可以使用 SQL Server 2008 R2 创建数据库,一旦创建了包括所有表格和存储过程等的数据库,然后将其复制粘贴到 Visual Studio 的 App_Data
文件夹中,以便用作本地数据库?
我发现使用 Visual Studio 项目创建数据库、表格和存储过程非常繁琐。 英文:
It is possible to create the database using SQL Server 2008 R2, once created with all tables and stored procedures etc. then copy and paste it into the Visual Studio App_Data
folder to be used as localdb?
I found that is very tedious creating the database with tables and stored procedure using the Visual Studio project.
答案1 {#1}
得分: 2
你可以(在某种程度上)做到这一点,但 SQL Server 2008 R2 不再受支持 ,已经很长时间没有得到支持了,而且最近仍然受支持的版本对于10GB以下的数据库是免费的。
实际上,SQL Server 2008 R2 早于 LocalDB。但是,我认为LocalDB仍然可以加载SQL Server 2008 R2数据库;只是实际的服务将运行较新的内容,但兼容级别为2008 R2(100)。
所以假设你迁移到一个实际受支持的版本,流程如下:
- 根据需要在服务器上创建数据库。
- 分离数据库以从原始服务器中分离。
- 将关联的(现在已分离的)*.mdf文件复制到适当的开发位置,并设置所需的连接字符串和部署选项。
此外,对于Web项目,通常最好使用Express Edition而不是LocalDB。 英文:
You can (sort of) do this, but SQL Server 2008 R2 is no longer supported , has not been supported for a very long time, and recent versions that are still under support are free for databases up to 10GB.
In fact, SQL Server 2008 R2 pre-dates LocalDB. However, I believe LocalDB can still load a SQL Server 2008 R2 database; it's just the actual service will then be running something newer, but at the 2008 R2 (100) compatibility level.
So assuming you move to an actually-supported version, the process looks like this:
- Create the database as needed on your server.
- Detach the database from the original server.
- Copy the associated (now-detached) *.mdf file to the appropriate development location and set the connection string and deployment options you need.
Additionally, for a web project you're almost always better off using Express Edition vs LocalDB anyway.