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