Jesper Lund Stocholm
Jesper Lund Stocholm

Reputation: 2013

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

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

Upvotes: 3

Views: 8220

Answers (1)

dvjanm
dvjanm

Reputation: 2381

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>

Upvotes: 5

Related Questions