[英]How to Add Extra Fields of FistName and LastName in Userprofile of Asp.Net MVC 4 Simple Membership?
我想在UserProfile Asp.Net简单成员身份中添加2个额外字段,但无法添加,也无法从Internet找到任何帮助。 请给我一些解决方案。
提前致谢
要将字段添加到SimpleMembership中的UserProfile
中(我假设您要使用迁移和EF):
Enable-Migration
) UserProfile
类(假设您使用的是Visual Studio 2012->新建项目-> ASP.NET MVC 4 Web应用程序-> Internet应用程序模板,将为您创建此模板)以添加新属性(示例下面) Add-Migration
命令更新您的数据库。 Update-Database
命令对您的开发数据库运行该迁移。 我已经在此答案中使用UserProfile提供了有关SimpleMembership如何工作的概述。 请注意,可以将UserProfile与所有其他类一起从UsersContext
移动到相同的DbContext,而不必在单独的上下文中。
SimpleMembership旨在与代码优先EF开发一起很好地使用,所以这就是我上面概述的过程。 一个例子更新UserProfile
类与Forename
, Surname
和LoginCount
场会是什么样子:
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
[MaxLength(40)]
[Required]
public string Forename { get; set; }
[MaxLength(40)]
[Required]
public string Surname { get; set; }
[Required]
public int LoginCount { get; set; }
}
参考文献:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.