【问题标题】:ServiceStack can't convert OrmLiteConnectionFactory to IDbConnectionFactoryServiceStack 无法将 OrmLiteConnectionFactory 转换为 IDbConnectionFactory
【发布时间】:2017-03-24 04:26:54
【问题描述】:

ServiceStack 新手,需要一些说明。

我希望将我的 ServiceStack 应用程序连接到 SQL Server,但遇到了问题。我读到 OrmLiteConnectionFactory 是从 IDbConnectionFactory 继承的,但是代码带有红色下划线:

container.Register<IDbConnectionFactory>(new OrmLiteConnectionFactory(Properties.Settings.Default.SQLEXPRESSConnectionString,
               SqlServerOrmLiteDialectProvider.Instance));

错误信息是:

Error   3   Argument 1: cannot convert from 'ServiceStack.OrmLite.OrmLiteConnectionFactory' to 'System.Data.Entity.Infrastructure.IDbConnectionFactory'

这是在AppHost.cs's Configure 方法中。

对此有何建议?非常感谢。

【问题讨论】:

    标签: servicestack ormlite-servicestack


    【解决方案1】:

    您注册了错误的IDbConnectionFactory 接口,因为您有超过 1 个您可以使用完全限定的类型名称,例如:

    container.Register<ServiceStack.Data.IDbConnectionFactory>(
        new OrmLiteConnectionFactory(connString,
        SqlServerDialect.Provider));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-29
      • 1970-01-01
      • 2015-09-04
      • 2016-05-26
      • 2015-08-11
      • 1970-01-01
      相关资源
      最近更新 更多