2015-07-20 50 views
0

新的ServiceStack並需要一些說明。ServiceStack無法將OrmLiteConnectionFactory轉換爲IDbConnectionFactory

我正在尋找將我的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方法。

對此有何建議?非常感謝。

回答

2

你註冊了錯誤的IDbConnectionFactory界面,因爲你有超過1,你可以使用完全限定的類型名稱,e.g:

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