LINQ运行命令时,无法识别的属性'名'错误 [英] Unrecognized attribute 'name' error when running linq command

查看:312
本文介绍了LINQ运行命令时,无法识别的属性'名'错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的APS.NET 4.5的Web应用程序使用实体框架6。

I am using Entity Framework 6 in my APS.NET 4.5 web application.

在运行以下命令:

using (var db = new booksEnteties())
{
    var books = from b in db.books
    select b;
} 

我收到以下错误:

I get the following error:

类型'System.Configuration.ConfigurationErrorsException的异常出现在System.Configuration.dll但在用户code没有处理

An exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll but was not handled in user code

在详细信息:

无法识别的属性'名'。

Unrecognized attribute 'name'.

和它指向我的web.config行111:

And it pointing me to the web.config line 111:

 <remove name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" />

当我删除了这条线,并尝试再次运行,我收到以下错误:

When I removed this line and try to run again, I get the following error:

出错创建System.Data这配置节处理程序:列'InvariantName'约束是唯一的。值MySql.Data.MySqlClient已经是present。

An error occurred creating the configuration section handler for system.data: Column 'InvariantName' is constrained to be unique. Value 'MySql.Data.MySqlClient' is already present.

我以为是什么东西在web.config中涉及到实体框架6的配置。

I assume that is something related to the Entity Framework 6 configuration in the web.config.

推荐答案

由于蒂姆·唐曾表示,如果使用的是实体框架6,你需要使用连接器/ NET 6.8.x.
你也应该加入到MySql.Data.Entity.EF6一个参考给你的项目。

As Tim Tang has stated, if you are using Entity Framework 6 for you need to use Connector/NET 6.8.x. You should also add a reference to the MySql.Data.Entity.EF6 to you project.

那么对于你的web.config文件中,这样的事情:

Then for your Web.config file, something like this:

 <entityFramework>
    <providers>
      <provider invariantName="MySql.Data.MySqlClient" 
                type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient"></remove>
      <add name="MySQL Data Provider" 
           invariant="MySql.Data.MySqlClient" 
           description=".Net Framework Data Provider for MySQL" 
           type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data,  Version=6.8.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>

看的,获取更多详情。

这篇关于LINQ运行命令时,无法识别的属性'名'错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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