0

I Have MySQL in AWS RDS which I want to access via C# Entity Framework. I've installed MySQL Visual Studio Plugin http://dev.mysql.com/downloads/file/?id=461390

And did on Some Project 'Right Click' -> 'Entity Framework' -> 'Reverse Engineer Code First'

After putting db credentials the model was created including app.config

enter image description here

app.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="algoventurelab_db1Context" connectionString="####"
      providerName="MySql.Data.MySqlClient" />
  </connectionStrings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

I now try to query to Datebase by using this code:

using System;
using System.Linq;
using Test3.Models;

namespace Test3
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var context = new algoventurelab_db1Context())
            {
                var query = (from c in context.Daily25Data
                    where c.Date == DateTime.UtcNow
                    select c).SingleOrDefault();

                Console.WriteLine(query);
            }
        }
    }
}

However when I try to run I get Exception:

An unhandled exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll

Additional information: No Entity Framework provider found for the ADO.NET provider with invariant name 'MySql.Data.MySqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

enter image description here

What seems to be the issue?

1 Answer 1

1

in entityFramework\providers section, just after the SqlClient provider add

    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity" />
Sign up to request clarification or add additional context in comments.

4 Comments

When I added it, I got ''MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity' registered in the application config file for the ADO.NET provider with invariant name 'MySql.Data.MySqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See go.microsoft.com/fwlink/?LinkId=260882 for more information.'
Are the MySQL dlls in output directory?
tried to copy, I guess it is meaning 'MySql.Data.dll' still not working
Probably you missed the EF provider for mysql. The name should be MySql.Data.Entities. You can find it on NuGet. You probably need also the latest ADO.Net provider (from NuGet as well). Before installing it delete the row I suggested before.

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.