The 'data source' keyword is not supported. (ASP.Net app, Entity-framework 5, Code first, migrations)

≯℡__Kan透↙ 提交于 2019-12-10 19:59:48

问题


I have an OData/WCF Data Services endpoint (ASP.Net site) that I would like to switch from using EF Code first datamodel with SQL Server 2012 as backend to EF Code first datamodel with LocalDB as backend - on our dev machines using Visual Studio 2012. Code is placed in TFS and we share the code between 5-6 developers.

Existing unit tests run smoothly after switching to LocalDB. The config for the unit test project is this:

<?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>

The configuration file for the OData endpoint is this

<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>

The problem is that whenever I press "save" in Visual Studio, it complains about "the data source"-keyword is not supported. The same message appears when trying to run the site using the configuration.

What am I doing wrong? According to other posts here the connection string looks spot on.

Edit: Removed double backslash from connection string - same results, though


回答1:


Try this connection string:

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


来源:https://stackoverflow.com/questions/19314320/the-data-source-keyword-is-not-supported-asp-net-app-entity-framework-5-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!