Asp.net mvc 3 EF代码优先和ASP.NET成员资格提供程序
我正在使用MVC3构建一个web应用程序。它拥有具有不同角色和权限的用户。我使用EF代码优先的方法创建数据库。我的用户模型类是:Asp.net mvc 3 EF代码优先和ASP.NET成员资格提供程序,asp.net-mvc-3,entity-framework,ef-code-first,asp.net-roles,Asp.net Mvc 3,Entity Framework,Ef Code First,Asp.net Roles,我正在使用MVC3构建一个web应用程序。它拥有具有不同角色和权限的用户。我使用EF代码优先的方法创建数据库。我的用户模型类是: public class Users { public int UserID { get; set; } public Name Name { get; set; } public Address Address { get; set; } public Contact Contact {
public class Users
{
public int UserID { get; set; }
public Name Name { get; set; }
public Address Address { get; set; }
public Contact Contact { get; set; }
}
public class Name
{
[Required, MaxLength(50), Display(Name = "First Name"), Column("FirstName")]
public string FirstName { get; set; }
[MaxLength(50), Display(Name = "Middle Name"), Column("MiddleName")]
public string MiddleName { get; set; }
[Required, MaxLength(50), Display(Name = "Last Name"), Column("LastName")]
public string LastName { get; set; }
}
public class Address
{
[Required, MaxLength(50), Display(Name = "Street"), Column("Street")]
public string Street { get; set; }
[Required, MaxLength(50), Display(Name = "City"), Column("City")]
public string City { get; set; }
[Required, MaxLength(50), Display(Name = "Country"), Column("Country")]
public string Country { get; set; }
[Required, MaxLength(5), Display(Name = "Postal Code"), Column("PostalCode")]
public string PostalCode { get; set; }
}
public class Contact
{
[Required, MaxLength(50), Display(Name = "Email"), Column("Email")]
public string Email { get; set; }
[Required, MaxLength(50), Display(Name = "Phone"), Column("Phone")]
public string Phone { get; set; }
[Required, MaxLength(50), Display(Name = "Fax"), Column("Fax")]
public string Fax { get; set; }
}
但是对于角色和身份验证,我希望使用
App\u Data
文件夹的默认aspnetdb.mdf
。如何将我的Users
表与aspnetdb.mdf
的默认Users
表链接?既然您似乎正在创建一个新的站点和数据库,我不会这样做,除非您出于任何原因不得不这样做
我将使用UserProfile来存储其他信息,如地址、电话、传真等。对于用户,请查看以添加自定义属性
也可能有帮助,它有点旧,但如果需要,它应该会帮助您。因为您似乎正在创建一个新网站和数据库,我不会这样做,除非您出于任何原因不得不这样做 我将使用UserProfile来存储其他信息,如地址、电话、传真等。对于用户,请查看以添加自定义属性 也可能有帮助,它有点旧,但如果需要,它应该会帮助你