【发布时间】:2015-01-28 13:38:50
【问题描述】:
我正在尝试使用 N 层架构和自定义 ASP.NET 身份服务和存储库创建 ASP.NET MVC 项目。我已经实现了自定义 UserStore
UserStore: UserIUserStore<User>, IUserPasswordStore<User>, IUserRoleStore<User>, IUserLoginStore<User>, IUserEmailStore<User>
我已经实现了注册和登录。现在我想通过社交网络实现登录,但我卡住了。
public class User : IUser<string>
{
[Required]
public string Id { get; set; }
[Required]
public string UserName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
[Required]
[DataType(DataType.EmailAddress)]
public string Email { get; set; }
[Required]
public string PasswordHash { get; set; }
public virtual ICollection<Role> Roles { get; set; }
public virtual ICollection<UserLoginInfo> Logins { get; set; }
}
UserLoginInfo 是 IUserLoginStore 中用于登录信息的 sealead 类。但是,如果我想添加迁移,则会收到此错误:
NtierMVC.Repositories.UserLoginInfo: : EntityType 'UserLoginInfo' has no key defined. Define the key for this EntityType.
Login: EntityType: EntitySet 'Login' is based on type 'UserLoginInfo' that has no keys defined.
我试图找到任何解决方案,如何使用外键将登录表扩展给用户(例如,如果您使用默认用户存储),但没有找到。有什么想法吗?
感谢您的帮助。
【问题讨论】:
标签: asp.net asp.net-mvc asp.net-identity