3

我有一个的OData/WCF数据服务端点(ASP.Net网站),我想从使用EF代码第一数据模型与SQL Server 2012的切换后端添加到使用LocalDB作为后端的EF Code第一个数据模型 - 在使用Visual Studio 2012的开发机器上。代码放置在TFS中,我们共享5-6个开发人员之间的代码。不支持'数据源'关键字。 (ASP.Net应用程序,实体框架5,代码首先,迁移)

现有单元测试切换到的LocalDB后平稳运行。在单元测试项目的配置是这样的:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="v11.0" /> 
     </parameters> 
    </defaultConnectionFactory> 
     </entityFramework> 
</configuration> 

的OData的端点配置文件是这样的

<configuration> 
    <configSections> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 
    <connectionStrings> 
    <add name="MyStorageContext" connectionString="Data Source=(LocalDb)\v11.0;Integrated Security=True" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="v11.0" /> 
     </parameters> 
    </defaultConnectionFactory> 
    </entityFramework> 
</configuration> 

的问题是,每当我按“保存”在Visual Studio中,它抱怨“数据源” - 关键字不受支持。尝试使用配置运行站点时会出现相同的消息。

我在做什么错?根据其他职位在这里连接字符串看起来。

编辑:从连接字符串中删除了双反斜线 - 相同的结果,虽然

回答

5

尝试这个连接字符串:

<connectionStrings> 
     <add 
      name="MyStorageContext" 
      providerName="System.Data.SqlClient" 
      connectionString="Server=(LocalDb)\v11.0;Database=DataBaseName;Trusted_Connection=true;MultipleActiveResultSets=true;"/> 
</connectionStrings> 
+0

谢谢你 - 那工作。我删除了“Database = DataBaseName”,这工作:-) –

+0

有谁知道这是为什么?我们无法控制我们收到的连接字符串,其中许多字符串将具有“数据源”而不是“服务器”。我没有选择更换每个“数据源”的情况。谢谢 –

相关问题