0
votes

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

1 Answers

1
votes

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

    <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity" />