Home:ALL Converter>Entity Framework 6 and MySQL, model first

Entity Framework 6 and MySQL, model first

Ask Time:2014-01-02T22:23:45         Author:Johan Svensson

Json Formatter

I have a problem using Entity Framework 6 with MySQL and doing so using model/database-first technique in ASP.NET C# MVC 3.

The current situation is that I’m getting the error:

Keyword not supported.
Parameter name: metadata

The metadata is specified in the connection string in the web.config –file:

<add name="SiteNameContainer" 
  connectionString="metadata=res://*/Models. SiteName.csdl|
    res://*/Models. SiteName.ssdl|
    res://*/Models. SiteName.msl;
    provider=MySql.Data.MySqlClient;
    provider connection string='server=127.0.0.1;
    user id=fire;password=fire_db;
    database=fire_dotnet'" 
  providerName="MySql.Data.MySqlClient" />

I tried to remove the metadata-section in the connectionString, but then its saying that the keyword “provider” is not supported, and then “provider connection string” not supported.

I also have these 2 sections in my web.config file:

<entityFramework>
    <providers>
        <provider invariantName="MySql.Data.MySqlClient" 
            type="MySql.Data.MySqlClient.MySqlProviderServices, 
            MySql.Data.Entity.EF6, Version=6.8.3.0, 
            Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </providers>
</entityFramework>
<system.data>
<DbProviderFactories>
    <clear />
    <remove invariant="MySql.Data.MySqlClient" />
    <add name="MySql.Data.MySqlClient" 
        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>

I have references to MySQL Net-connector 6.8.3 files (MySql.Data, MySql.Data.Entity.EF6, MySql.Web).

My requirments are that I must use MySQL and Entity Framework 6, and the changelog for the .NET connectior says that 6.8.x added support for MySQL.

I’m out of ideas, hopefully someone can help me with this. Thanks in advance.

Author:Johan Svensson,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/20885034/entity-framework-6-and-mysql-model-first
yy