2

I have installed the MySql Connector 6.6.5 from http://dev.mysql.com/downloads/connector/net/

I have added it as a reference in my asp.net MVC website (please see screenshots below), and changed "Copy local" to true.

However, when I get to the line:var calls = db.Calls.ToList(); I get the error:

Unable to find the requested .Net Framework Data Provider. It may not be installed.

I've included my code below. Can anyone please let me know what I'm missing?

Thanks, Mark

Controller Call.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MySql.Data;
using MySql.Data.Entity;
using MySql.Data.MySqlClient;
using MySql.Web;
using System.Data;

namespace bm.Controllers
{
public class CallController : Controller
{
    private CallContext db = new CallContext();

    //
    // GET: /Calls/
    public ActionResult Index()
    {
        var calls = db.Calls.ToList();
        return View(calls);
    }
  }
}

CallContext.cs

using bm.Models;
using System.Data.Entity;
public class CallContext : DbContext
{
    static CallContext()
    {

    }
    public CallContext()
        : base("callsConn")
    {

    }

    public DbSet<Call> Calls { get; set; }
}

Web.Config Connection String:

 <connectionStrings>
  <add name="callsConn" connectionString="Server=xxx;Port=3306;Database=xxxx;Uid=root;Pwd=;" providerName="MySql.Data.MySqlClient" />
 </connectionStrings>

References:

References

1 Answer 1

14

Update

I seem to have solved this by adding the following to my web.config:

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

Hope it helps someone else.

Mark

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

2 Comments

I've got a different client version I think. How do I figure out the version and publickeytoken?
I got error like "Failed to find or load the registered .Net Framework Data Provider.". In local pc everything works fine but when i am host to godaddy nothing is work. Please help me for solving this

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.