Unrecognized attribute 'name' error when running linq command

后端 未结 3 1434
萌比男神i
萌比男神i 2021-01-15 04:21

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

When running the following command:

using (var db = new booksEnteties())
{
    var          


        
相关标签:
3条回答
  • 2021-01-15 04:57

    Just adding a summary of versions

    • For EF4, use Connector/NET 6.6.x (current GA is 6.6.6)
    • For EF5, use Connector/NET 6.7.x (current GA is 6.7.4) or Connector/NET 6.8.x (current GA is 6.8.3).
    • For EF6, use Connector/NET 6.8.x (current GA is 6.8.3).

    in EF5 or less, all ok. in EF6, you need to use mysql connector 6.8.x, and add DbConfigurationTypeAttribute to you DbContext:

    [DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
    public class DemoContext : DbContext{}
    

    which MySqlEFConfiguration is in MySql.Data.Entity.EF6.dll in 6.8.x. Have a try!

    0 讨论(0)
  • 2021-01-15 05:08

    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.

    enter image description here

    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>
    

    Look at this for more details.

    0 讨论(0)
  • 2021-01-15 05:11

    The error is very specific... Its complaining about the attribute 'Name' Your problem is on this line:

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

    Name is invalid here, just remove it so it should be like this:

    <remove invariant="MySql.Data.MySqlClient" />
    
    0 讨论(0)
提交回复
热议问题