ServiceStack.Ormlite允許我們使用Schema屬性來修飾數據庫表類,以表示它們屬於數據庫中的哪個模式。是否可以指定ServiceStack的身份驗證功能模式?
這是偉大的除了,它的出現,那些由驗證功能創建的所有表。是否可以指定Auth表應該屬於哪個模式?我寧願不使用自定義類純粹用Schema屬性來裝飾。
如果不是,我想我應該要求改變某處?
編輯1 - 以下mythz的建議
我已經在我的初始化構造函數添加的屬性..
public class AuthenticationInitialisation : AppInitialisation
{
private readonly IAppSettings _appSettings;
public AuthenticationInitialisation(IAppSettings appSettings)
{
_appSettings = appSettings;
typeof(UserAuth).AddAttributes(new SchemaAttribute("Admin"));
typeof(UserAuthDetails).AddAttributes(new SchemaAttribute("Admin"));
typeof(UserAuthRole).AddAttributes(new SchemaAttribute("Admin"));
}...
我已經從我的SQL用戶刪除默認的架構和我得到的例外的DropAndRecreateTables()...
var authRepo = (OrmLiteAuthRepository)appHost.TryResolve<IUserAuthRepository>();
if (_appSettings.Get("RecreateAuthTables", false))
authRepo.DropAndReCreateTables(); //Drop and re-create all Auth and registration tables
else...
例外讀取
無法刪除表「USERAUTH」,因爲它不存在,或者您沒有權限。
通過SQL事件探查器驗證顯示出下面通過傳遞到SQL服務器
DROP TABLE "UserAuth"
EDIT 2 - 以下更改MyGet預發行ServiceStack版本
現在我正在以下錯誤..
發生類型'System.MissingMethodException'的異常紅色ServiceStack.dll但在用戶代碼中沒有處理
其他信息:未找到方法:「無效ServiceStack.MetadataTypesConfig..ctor(System.String,布爾值,布爾,布爾值,布爾,布爾值,布爾型,系統。字符串,布爾,布爾,布爾,布爾,布爾,System.Nullable`1)'。
堆棧跟蹤..
在ServiceStack.NativeTypesFeature..ctor() 在ServiceStack.ServiceStackHost..ctor(字符串服務名,大會[] assembliesWithServices) 在ServiceStack.Host.HttpListener。 HttpListenerBase..ctor(String serviceName,Assembly [] assembliesWithServices) at ServiceStack.AppHostHttpListenerBase..ctor(String serviceName,Assembly [] assembliesWithServices) at MyProduct.AppHost..ctor(IEnumerable`1 initialisations)in d:\ dev \ App_Code \ AppHost.cs:line 14 at MyProduct.G在d:\ dev \ Global.asax.cs中的lobal.Application_Start(Object sender,EventArgs e):line 29
對我的AppHost構造函數..
public AppHost(IEnumerable<IAppInitialisation> initialisations) : base("RESTful Web API", typeof(SystemsService).Assembly)
{
if (initialisations == null)
{
_initialisations = new IAppInitialisation[0];
}
else
{
_initialisations = initialisations.ToArray();
}
}
如果使用模式是進入下ServiceStack版本然後我再等一等,設置SQL用戶的默認架構現在...
感謝回去我@mythz - 我已經更新了你的建議的解決方案 – Drammy 2015-02-06 10:06:01
@Drammy嗯看起來發現的問題一樣,我只擴展架構的支持刪除/創建表的API最近[來自這個提交](https:// githu b.com/ServiceStack/ServiceStack.OrmLite/commit/103c0410c39d3033598e05629c1705decc564e34)。你可以再次嘗試使用[MyGet上的最新預發佈v4.0.37](https://github.com/ServiceStack/ServiceStack/wiki/MyGet)。此外,您還需要確保在對使用它們的代碼進行任何配置/初始化之前添加任何動態屬性。 – mythz 2015-02-06 10:40:29
感謝您的幫助@mythz - 您必須堅持維護一個偉大的產品,同時像您一樣支持社區!無論如何,如果模式的使用將進入下一個版本,那麼我將等到該版本發佈並立即設置SQL用戶的默認模式。 – Drammy 2015-02-06 11:39:12