不支持“数据源”关键字。 (ASP.Net应用程序,Entity框架5,代码第一,迁移) [英] The 'data source' keyword is not supported. (ASP.Net app, Entity-framework 5, Code first, migrations)

查看:280
本文介绍了不支持“数据源”关键字。 (ASP.Net应用程序,Entity框架5,代码第一,迁移)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个OData / WCF数据服务端点(ASP.Net站点),我想从使用EF代码第一个数据模型与SQL Server 2012作为后端切换到EF代码第一个数据模型与LocalDB作为后端 - 在我们的开发机使用Visual Studio 2012.代码放置在TFS中,我们在5-6个开发人员之间共享代码。

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.

现有的单元测试在切换到LocalDB后运行顺利。单元测试项目的配置如下:

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>

OData端点的配置文件为

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.

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

Removed double backslash from connection string - same results, though

推荐答案

尝试此连接字符串:

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

这篇关于不支持“数据源”关键字。 (ASP.Net应用程序,Entity框架5,代码第一,迁移)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆