0

I'm trying out ASP.NET MVC4 with MySQL. But I can't generate the Controller from the Entity Framework Model. I followed the following blog : http://blog.jongallant.com/2013/04/mysql-aspnet-mvc-entity-framework.html#.UmsDyPnbNLO

After I create the Entity Model, I go to create the controller and get the following error : Here is the Error message

I'm using Visual Studio 2012 with MySQL Connector/Net 6.7.4 and I have MySQL for Visual Studio 1.0.2 installed.

ngm
  • 7,277
  • 1
  • 53
  • 62
NeerPatel
  • 863
  • 6
  • 19

2 Answers2

1

It looks as if the MySQL data provider is not being referenced in your project correctly.

  • Add references to MySql.Data and MySql.Data.Entity to your project.
  • Add the following to your web.config:

    <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, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
        </DbProviderFactories>
    </system.data>
    

See this question for more information: MySQL connector 6.7.4 and Entity Framework 5 exceptions.

Community
  • 1
  • 1
ngm
  • 7,277
  • 1
  • 53
  • 62
1

I wrote a blog post about this. You not only need to add what ngm point out, but also to remove references to entityframework from your config, as it just confuses it. I know it sound strange, but it is the best way I have found so far. Also be sure to use EF 5, not 6, with the latest version of MySql .net connector, as it does not work with EF6 yet.

BernardG
  • 1,956
  • 3
  • 17
  • 25