2012-08-28 18 views
4

我正在使用EF Code First(.NET 4.5 + VS2012)。我的项目正在创建和使用LocalDB。我的SQL Server Express也安装在我的机器上(2008R2)。我没有改变任何配置,但它切换到使用SQL Server Express。Entity Framework更改为SQL Server Express,我如何将其更改回Localdb

我现在已经停在我的SQL Server实例,每当我试图重新使用Update-Database我得到以下信息数据库:

System.Data.ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct. ---> System.Data.ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. ---> System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

我的配置文件有以下EF配置:

<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
    <parameters> 
    <parameter value="v11.0" /> 
    </parameters> 
</defaultConnectionFactory> 

有什么建议吗?我宁愿使用Localdb而不是SQL Server Express。

+0

LocalDB是SQL Express的特殊版本。 –

+0

@LadislavMrnka是的,但数据库正在我的SQL Express实例中创建,而不是我的Localdb实例。 – Sam

回答

4

事实证明,由于某种原因,GUI app.config引用SqlConnectionFactory而不是LocalDbConnectionFactory。解决这个问题解决了它。

+0

该文件在哪里? – shim

相关问题