ServiceStack - UserAuth "Id" 是 INT 而 RavenDb 期望 "Id" 是 STRING

ServiceStack - UserAuth "Id" is INT while RavenDb expects "Id" to be STRING

我正在尝试为 RavenDb 实施 ServiceStack 身份验证和授权。 ServiceStack UserAuth 模型将 属性 "Id" 作为 Int,而 RavenDb 除了 "Id" 是字符串。

当我尝试创建新用户时出现以下异常:

Message=Cannot set identity value 'UserAuths/1-A' on property 'Id' for type 'ServiceStack.Auth.UserAuth' because property type is not a string. Source=Raven.Client

我可以实施 custom_UserAuth table 忽略 ServiceStack UserAuth table 吗?这是唯一的方法吗?

Auth 存储库必须至少实现 IUserAuth but you can use your own concrete UserAuth Table which is what the RavenDbUserAuthRepository 允许使用通用 RavenDbUserAuthRepository<TUserAuth, TUserAuthDetails>

例如:您可以使用自己的 MyUserAuthMyUserAuthDetails 创建自定义 MyRavenDbUserAuthRepository 类:

public class MyRavenDbUserAuthRepository 
  : RavenDbUserAuthRepository<MyUserAuth, MyUserAuthDetails>, IUserAuthRepository
{
    public RavenDbUserAuthRepository(IDocumentStore docStore) : base(docStore) { }
}

否则看起来 RavenDB 让你 customize which property to use as its Identity.