MySQL DbConnection
c#, entity-framework, mysql, mysql.data, visual-studio-2012
Solution
Apparently what I needed was
<clear />
instead of
<remove .. />
Problem
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>`