EntityFramework:无法确定类型为' MySql.Data.MySqlClient.MySqlClientFactory'的提供者工厂的提供者名称。

时间:2017-01-20 03:13:50

标签: c# mysql entity-framework ado.net entity-framework-6

我正在尝试在另一台计算机上运行我的应用程序并收到以下错误:

  

无法确定类型为' MySql.Data.MySqlClient.MySqlClientFactory'的提供程序工厂的提供程序名称。确保在应用程序配置中安装或注册了ADO.NET提供程序。   我一直试图找出问题所在,我的配置如下:

User

                                直接运行exe时,应用程序在我的PC上运行正常,但是当我将应用程序文件,dll和配置文件移动到服务器时,它会出现此错误。

我正在使用DBContext类直接设置连接字符串:

<connectionStrings>
    <add name="RTIDBModel" connectionString="myConnectionString" providerName="MySql.Data.MySqlClient" />
    <add name="RTIEmailServer" connectionString="server=smtp.Gmail.com;user id=myEmailService;password=123MyPassword;"/>
  </connectionStrings>

有关可能导致此异常的原因的任何想法?

异常详细信息:

public class RtiContext : DbContext
{
        public RtiContext():base(System.Configuration.ConfigurationManager.ConnectionStrings["RTIDBModel"].ConnectionString)
        {
            this.Configuration.LazyLoadingEnabled = false;
        }

     .........

}

我引用了以下dll:

ExceptionMessage: Unable to determine the provider name for provider factory of type 'MySql.Data.MySqlClient.MySqlClientFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.
StackTrace:    at System.Data.Entity.Utilities.DbProviderFactoryExtensions.GetProviderInvariantName(DbProviderFactory factory)
   at System.Data.Entity.Infrastructure.DependencyResolution.DefaultInvariantNameResolver.GetService(Type type, Object key)
   at System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.<>c__DisplayClass1.<GetService>b__0(Tuple`2 k)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.GetService(Type type, Object key)
   at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r)
   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.ResolverChain.GetService(Type type, Object key)
   at System.Data.Entity.Infrastructure.DependencyResolution.RootDependencyResolver.GetService(Type type, Object key)
   at System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r)
   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.ResolverChain.GetService(Type type, Object key)
   at System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver`2.GetService(Type type, Object key)
   at System.Data.Entity.Infrastructure.DependencyResolution.DbDependencyResolverExtensions.GetService[T](IDbDependencyResolver resolver, Object key)
   at System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInvariantName(DbConnection connection)
   at System.Data.Entity.Internal.InternalConnection.get_ProviderName()
   at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
   at System.Data.Entity.Internal.LazyInternalContext.get_ProviderName()
   at System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext context)
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
   at System.Linq.Queryable.OrderByDescending[TSource,TKey](IQueryable`1 source, Expression`1 keySelector)
   at RTI.DataBase.Model.Repositories.SourceRepository.GetAllSources()

0 个答案:

没有答案