解决方案——Connect to an old database using LocalDB in VS

原创 2015年03月12日 12:56:47

解决无法在高版本VS中连接低版本SQlServer数据库文件的问题

当我们尝试在高版本VS中将一个低版本SQLServer数据库文件添加到模型中的时候,可以会得到这样一个提示:

This database file is not compatible with the current instance of SQL Server. To resolve this issue, you must upgrade the database file by creating a new data connection, or you must modify the existing connection to this database file. For more information, see http://go.microsoft.com/fwlink/?LinkId=235986

然后我们又不得不发现Microsoft上得不到直接有用的解决方案。

其实我们可以这样做:
1.打开SQL Server Management Studio,添加目标数据库文件。
2.在VS中打开Server Explorer(View -> Server Explorer),新建数据库连接至刚刚导入SQLServer的库,Server name置为(localdb)\v11.0
3.点击我们刚刚添加的Data Connection,选择Properties,将Connection String的值替换Web.config中的数据库连接信息。
4.在Models文件夹中添加Models,选择我们刚刚建立的连接信息,发现可以成功了!

以下引自stackoverflow原文:

1.Forget about trying to open the old SQL Server Express .mdf file in Visual Studio 2012. During the conversion process of an old VS 2010 solution to VS 2012 it tells you can do that by just double clicking the database file and upgrade it to use LocalDb instead. That’s a complete lie! :D
2.Open SQL Server Management Studio, select the Databases node, right click it and select Attach….
3.Provide the path for the .mdf file, click OK and then you should be good to go.
4.Now inside Visual Studio 2012, open Server Explorer (menu View -> Server Explorer), right click Data Connections and then select Add Connection…. In Server name: put (localdb)\v11.0 and in Connect to a database: select the database you attached previously.
5.Right click the Data Connection just added in Solution Explorer and select Properties. Copy the Connection String property and replace the Web.Config or App.Config one with this value.
——see here

相关文章推荐

VC++ Unable to register this add-in because its DllRegisterServer returns an error 解决方案

1.下载VC6LineNumberAddin插件及注册文件。(以下是参考链接:) http://codefish.googlecode.com/files/VC%E6%98%BE%E7%A4%B...

How can I connect Unity to an SQL database in order to implement an MMO?

问: Hello, first of all I'd like to thank each and everyone who has dedicated their time into pr...
  • Koupoo
  • Koupoo
  • 2012年07月12日 15:16
  • 358

windows下mysql提示access denied for user ''@'localhost' to database解决方案

windows下mysql提示access denied for user ”@’localhost’ to database解决方案用root帐号连上mysql,语句为“mysql -u root”...

MySQL 2002问题解决方案 - Can't connect to local MySQL server through socket...

mysql,mysqldump,mysqldump,php连接mysql服务常会提示下面错误:ERROR 2002 (HY000): Can't connect to local MySQL serv...

IDA Pro调试出现"Could not connect to 127.0.0.1: 由于目标计算机积极拒绝,无法连接。"的解决方案

如图,在所有前期配置完成后,进行设备连接调试的时候,出现了"Could not connect to 127.0.0.1: 由于目标计算机积极拒绝,无法连接。"的错误提示,解决办法其实很简单: 方...

启动SQL提示"Can't connect to local MySQL server through socket '/tmp/mysql.sock"参考解决方案

写了个脚本可以定时访问本地安装的mySQL,启动本地sql时,突然报下面错误: ERROR 2002 (HY000): Can't connect to local MySQL server ...
  • lizitao
  • lizitao
  • 2016年11月17日 14:09
  • 1991

Mysql的root账户忘记密码或mysqladmin: connect to server at 'localhost' failed解决方案

无论是忘记了mysql的密码还是出现错误mysqladmin: connect to server at 'localhost' failed 都可以通过修改密码来解决问题 一、修改root账户的登录...

MYSQL用法(十二) Can't connect to MySQL server on 解决方案

一  错误编号:2003 1.1 问题分析:无法连接到 mysql 服务器,可能的情况为: 1、mysql 服务没有启动,一般是在异常的情况下 mysql 无法启动导致的,比如无可用的磁盘...

Can't connect to MySQL server on 'XXXX' (10055) 解决方案

最近做一个服务器端项目,要用到MySQL 数据库,但在大用户量并发的情况下会出现 Can't connect to MySQL server on'localhost' (10055) 错误,花了...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:解决方案——Connect to an old database using LocalDB in VS
举报原因:
原因补充:

(最多只允许输入30个字)