To upgrade the project database to use SQL Server LocalDB Express, …
2015-09-08 15:54
761 查看
Ok, fifth time I’ve had to Google this (I keep forgetting the exact steps), and unfortunately not enough people have actually written about this error message for the first 2 to 3 pages in the Google search to be of any use. So let me make this one short
and sweet.
You get the following error dialog
The Web project ‘YourProjectNameHere’ requires SQL Server Express, which is not installed on this computer. The recommended database engine for Visual Studio 2012 is SQL Server LocalDB Express.
To upgrade the project database to use SQL Server LocalDB Express, double click the database file and follow the instructions. Note: After this upgrade, the project database cant be modified using earlier
versions of Visual Studio. To continue using SQL Server Express for this project, install it from the Microsoft Download Center.
Ok, this sure seems like it is a straight forward thing to fix, but it isn’t (doh). So why isn’t it an easy thing to fix? because with EF and Code First and Design First more and more people are pushing up examples that
don’t actually have a database in them. They depend on EF to JIT build the database for the project (and for you) the first time you run their sample.
That of course means you can’t double click on the project database as instructed by the helpful Microsoft dialog, because there IS no project database to double click on. But wait a sec, if there is no project database how is Visual Studio 2012 determining
that you aren’t using the latest greatest from Microsoft. Well because despite what the dialog says, VS 2012 is actually NOT looking at the database, it is looking in the project’s active .config file and the connection strings therein.
So for the
example of the project above in the web.config here is what comes from the author for the Connection strings entries
So the problem here is the section that says “data source=.\SQLEXPRESS”. VS2012 is reading that in the .config file and warning you. Now if there was a database file in the project you
could double click it and a wizard would run that would make the necessary changes for you. BUT if the project author left out the database, then you have a chicken / egg problem, you can’t create the database to upgrade it until you have already
upgraded the database.
So how do you get around this problem? Easy, just need to make a quick change in the .config file and you are ready to rock
What we need to do is change the .\SQLEXPRESS to indicate instead the LocalDB engine and then EF Code First / Model First will work just fine and your database will be created without requiring you to install SQLExpress.
Change
To
And you are done.
Ok, fifth time I’ve had to Google this (I keep forgetting the exact steps), and unfortunately not enough people have actually written about this error message for the first 2 to 3 pages in the Google search to be of any use. So let me make this one short
and sweet.
You get the following error dialog
The Web project ‘YourProjectNameHere’ requires SQL Server Express, which is not installed on this computer. The recommended database engine for Visual Studio 2012 is SQL Server LocalDB Express.
To upgrade the project database to use SQL Server LocalDB Express, double click the database file and follow the instructions. Note: After this upgrade, the project database cant be modified using earlier
versions of Visual Studio. To continue using SQL Server Express for this project, install it from the Microsoft Download Center.
Ok, this sure seems like it is a straight forward thing to fix, but it isn’t (doh). So why isn’t it an easy thing to fix? because with EF and Code First and Design First more and more people are pushing up examples that
don’t actually have a database in them. They depend on EF to JIT build the database for the project (and for you) the first time you run their sample.
That of course means you can’t double click on the project database as instructed by the helpful Microsoft dialog, because there IS no project database to double click on. But wait a sec, if there is no project database how is Visual Studio 2012 determining
that you aren’t using the latest greatest from Microsoft. Well because despite what the dialog says, VS 2012 is actually NOT looking at the database, it is looking in the project’s active .config file and the connection strings therein.
So for the
example of the project above in the web.config here is what comes from the author for the Connection strings entries
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
So the problem here is the section that says “data source=.\SQLEXPRESS”. VS2012 is reading that in the .config file and warning you. Now if there was a database file in the project you
could double click it and a wizard would run that would make the necessary changes for you. BUT if the project author left out the database, then you have a chicken / egg problem, you can’t create the database to upgrade it until you have already
upgraded the database.
So how do you get around this problem? Easy, just need to make a quick change in the .config file and you are ready to rock
What we need to do is change the .\SQLEXPRESS to indicate instead the LocalDB engine and then EF Code First / Model First will work just fine and your database will be created without requiring you to install SQLExpress.
Change
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|DatabaseName.mdf;User Instance=true"
To
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\DatabaseName.mdf;Integrated Security=True"
And you are done.
相关文章推荐
- Access数据库的常用数据类型和alter的用法
- Memcached查找命令
- Nodejs+Express4.x+mongodb简要介绍
- Oracle基础语句大全
- SQL语句case when(需完善)
- 自用—oracle分析函数,合并重复列
- jboss-as-7.1.1.Final 数据源 Oracle DataSource 配置
- 【连载】数据库审计产品常见缺陷(五)参数审计错误
- Oracle 学习之性能优化(十一)物化视图
- Redis管理监控软件
- 数据库中,连接有哪些不同类型?请说明这些类型之间的差异,以及为何在某些情形下,某种连接会比较好。
- Hibernate基于注解方式配置来实现实体和数据库之间存在某种映射关系
- mysql 查询语句
- ActiveReports如何使用MySQL数据库
- plsql链接oracle Could not load "……\bin\oci.dll"异常
- Ubuntu 安装mysql和简单操作
- 基于key-value的存储系统Redis
- Mysql innodb_flush_log_trx_commit 简单调优
- oracle_load_csv
- Oracle ASCII编码 转字符串