简体   繁体   中英

Error loading assembly 'MySql.Data.MySqlClient' when deploying ASP.net application to AWS

I am getting the below exception message when I publish my Asp.NET application to an AWS Elastic Beanstalk intance. The database is on Amazon RDS. The application runs fine locally with a local MySql database. I've tried many of the suggested answers on Stack Overflow but none have proven to work yet. Has anybody had this issue when deploying a .NET application?

The Entity Framework provider type 'MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' 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 http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName)

at System.Data.Entity.Internal.AppConfig.<.ctor>b__2(ProviderElement e)

at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()

at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)

at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

at System.Lazy`1.CreateValue()

at System.Lazy`1.LazyInitValue()

at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.RegisterDbProviderServices()

at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetServiceFactory(Type type, String name)

at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)

at System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetService(Type type, Object key)

at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()

at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)

at System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver`2.GetService(Type type, Object key)

at System.Data.Entity.Infrastructure.DependencyResolution.DbDependencyResolverExtensions.GetService[T](IDbDependencyResolver resolver)

at System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection internalConnection, DbCompiledModel model)

at MichHerbAcumaticaApi.Models.ApplicationDbContext.Create()

at Microsoft.AspNet.Identity.Owin.IdentityFactoryMiddleware`2.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.d__2.MoveNext() --- End of stack trace from previous location where exception was thrown ---

at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar)

at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

<packages>
  ......
  <package id="MySql.Data" version="6.9.9" targetFramework="net452" />
  <package id="MySql.Data.Entity" version="6.9.9" targetFramework="net452" />
  <package id="MySql.Web" version="6.9.9" targetFramework="net452" />
  .....
</packages>

I've tried the following solutions with no luck: https://stackoverflow.com/a/40574224/5481661

Entity Framework Provider type could not be loaded?

.NET MySQL Connector Conflicting DbProviderFactories

Please check if you have followed all the steps from the below mySQL documentation. As per the documentation it states that "Unless MySQL Connector/Net was installed with the standalone MSI or MySQL Installer, which adds the reference, insert the following data provider information into the app.config or web.config file:" https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM