3

I'm getting a set of errors that I don't know how to reconcile. I'm using EntityFramework5 as that is the latest supported version of EF for MySql.Data & MySql.Data.Entity. It is App.Config that is throwing the errors. Here are the two alternations I have been trying and have no solution for.

   <entityFramework>
     <defaultConnectionFactory type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
     <providers>
       <provider invariantName="MySql.Data.MySqlClient"
                type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity" />
     </providers>
   </entityFramework>

In this example I get the error: {"Unrecognized element 'providers'. (C:\\Users\\recursor\\Documents\\Visual Studio 2012\\Projects\\CS3280\\Final Project\\IR\\ConsoleApplication2\\bin\\Debug\\ConsoleApplication2.vshost.exe.Config line 16)"}

From what I understand providers is not supported in EF5 so I have tried using this.

   <entityFramework>
     <defaultConnectionFactory type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
     <contexts>
       <context type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity" />
     </contexts>
   </entityFramework>

In this example I get the error: {"Required attribute 'invariant' not found. (C:\\Users\\recursor\\Documents\\Visual Studio 2012\\Projects\\CS3280\\Final Project\\IR\\ConsoleApplication2\\bin\\Debug\\ConsoleApplication2.vshost.exe.Config line 34)"}

I tried putting invariant in and get a warning The 'invariantName' attribute is not allowed (nor is invariant).

If I put invariant in, it gets this error: {"Required attribute 'invariant' not found. (C:\\Users\\recursor\\Documents\\Visual Studio 2012\\Projects\\CS3280\\Final Project\\IR\\ConsoleApplication2\\bin\\Debug\\ConsoleApplication2.vshost.exe.Config line 34)"}

So it seems I have a situation where I can't use one, but the other doesn't support the invariant type. I don't know how to resolve this. I have been able to connect to the DB and the connection string work. I just search or modify any data using the entity framework.

I tried adding this, but it didn't help either.

   <system.data>
     <DbProviderFactories>
       <remove name="MySQL Data Provider"/>
       <add name="MySQL Data Provider"
          invariant="MySql.Data.MySqlClient"
          description=".Net Framework Data Provider for MySQL"
          type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
   </system.data>

EDIT 1:

Line 16 is <providers>.

Line 34 is <DbProviderFactories>

4
  • And where is line 16 and 34?? Commented Nov 18, 2013 at 7:02
  • I just added that in my edit. Thanks Commented Nov 18, 2013 at 7:06
  • Have you edited your reference? Did you already added MySQL to your project? Commented Nov 18, 2013 at 7:37
  • Yes both MySql.data and MySql.data.entities both version 6.7.4.0 from NuGets Commented Nov 18, 2013 at 15:39

1 Answer 1

5

Apparently what I needed was

<clear />

instead of

<remove .. />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.