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.

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

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.