Click here to Skip to main content
15,910,878 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have just developed my sales site according to the following tutorial:
Which can be found on Microsoft here (mvc-music-store):
https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions/mvc-music-store/
So I created a new project from Visual Studio 2017 and the result is super functional, so everything is fine.
I now plan to develop it on my existing site with the same Framework 4.7 (which already works with Mysql) and there at the HomeController level I get the following message:
C#
System.Data.Entity.Core.ProviderIncompatibleException : 
Provider did not return ProviderManifestToken string.

C#
private List<Album> GetTopSellingAlbums(int count)
     {

         return storeDB.Albums
             .OrderByDescending(a => a.OrderDetails.Count())
             .Take(count)
             .ToList();
     }


I have in my Global.asax.cs the launch of the two Db...
C#
protected void Application_Start()
      {
          DbConfiguration.SetConfiguration(new MySqlEFConfiguration());

          Database.SetInitializer(new SampleData());


And this in the Web.config:

C#
<connectionStrings>


 <add name="Site_LsB_MVCEntities" providerName="System.Data.SqlServerCe.4.0" connectionString="Data Source=|DataDirectory|Site_LsB_MVC.sdf;"  />

  <add name="DefaultConnection" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;port=***;database=_Bdd_MVC_Photo;userid=Bdd_MVC_Photo;password=****;persistsecurityinfo=True" />
  <add name="TypeVisiteur" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;port=****;database=_Visiteurs;userid=Bdd_MVC_Visiteur;password=****;persistsecurityinfo=True" />
</connectionStrings>



The two configs separately work well, but there is a problem when they are combined...

How to solve this problem, would it be because of the Provider?
C#
<entityFramework>
   <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
     <parameters>
       <parameter value="System.Data.SqlServerCe.4.0" />
     </parameters>
   </defaultConnectionFactory>

   <providers>

     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
     <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
     <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
   </providers>
 </entityFramework>

For once I need a pro in the matter.

Thank you in advance.

What I have tried:

Quote:
<add name="Site_LsB_MVCEntities"
="" connectionstring="Data Source=.;Initial Catalog=Site_LsB_MVC;Integrated Security=SSPI" providername="System.Data.SqlClient">
Posted
Updated 21-Feb-22 21:20pm

1 solution

Your problem lies in the provider for SQL vs MYSQL, including configurations as the SQL is also version sensitive. a Quick search did provide quite a few solutions HERE.

This exception is also thrown in cases where EF is unable to locate a Connection String to use. If you-re working in a multi-layered application, make sure the connection String is added to your client application, instead of the class library that contains you data access code.

You can also get this error if you upgrade Nuget references in an EntityFramework project that uses MySql.Data.Entity (latest version is 6.10.X) and MySql.Data (latest version is 8.0.X). Those version numbers should match. You should use the MySql.Data.EntityFramework package with MySql.Data version 8.0 and after, and the MySql.Data.Entity package with versions 6.10 and before.

Try THIS link for more information on this.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900