asp.net – 不支持每种类型的多个对象集.对象集’ApplicationUse
发布时间:2020-12-16 04:19:43 所属栏目:asp.Net 来源:网络整理
导读:我陷入了一个奇怪的问题. 我正在学习MVC 5,几乎所有内容都是由内置模板创建的. 我只添加了一个类历史 public class History{ [Key] public DateTime Date { get; set; } public virtual ApplicationUser User { get; set; } public string ItemName { get; s
我陷入了一个奇怪的问题.
我正在学习MVC 5,几乎所有内容都是由内置模板创建的. public class History { [Key] public DateTime Date { get; set; } public virtual ApplicationUser User { get; set; } public string ItemName { get; set; } } 在内置的ApplicationUser中: public class ApplicationUser : IdentityUser { public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this,DefaultAuthenticationTypes.ApplicationCookie); // Add custom user claims here return userIdentity; } public virtual ICollection<History> Histories { get; set; } } 这是错误消息: Multiple object sets per type are not supported. The object sets 'ApplicationUsers' and 'Users' can both contain instances of type 'MyOnlineShopping.Models.ApplicationUser'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Multiple object sets per type are not supported. The object sets 'ApplicationUsers' and 'Users' can both contain instances of type 'MyOnlineShopping.Models.ApplicationUser'. Source Error: Line 124: { Line 125: var user = new ApplicationUser() { UserName = model.Email,Email = model.Email }; Line 126: IdentityResult result = await UserManager.CreateAsync(user,model.Password); Line 127: if (result.Succeeded) Line 128: { Source File: f:WorkplaceMyOnlineShoppingMyOnlineShoppingControllersAccountController.cs Line: 126 解决方法
我最终将ApplicationUser重命名为User,重新加载,一切都神奇地开始工作.
看起来模板有点出没了. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- asp.net – 在VMware主机中扩展 – 添加vCPU或VM
- ASP.NET 4 URL路由Web表单打破了我对样式,脚本,图
- asp.net – 使用HttpHandler流式传输数据库图像
- asp.net-mvc – 如何使用ASP.NET MVC和表单身份验
- asp.net-core – asp.net核心自定义模型绑定器,仅
- 是否有任何ASP.NET应用程序来监控在线用户和页面
- asp.net-mvc – ASP.NET MVC 3多语言SEO
- asp.net-mvc – 我应该如何管理ASP.NET MVC 4应用
- asp.net-mvc-5 – 在默认的MVC5应用程序的帐户关
- .net – 使用FileStreamResult,MemoryStream是如
热点阅读