2

我正在使用MVC 3構建Web應用程序。它具有不同角色和特權的用戶。我正在使用EF Code First方法創建數據庫。用戶我的模型類:EF Code First和ASP.NET會員供應商

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_Dataaspnetdb.mdf。如何將我的Users表與aspnetdb.mdf的默認Users表相關聯?

回答

0

由於您似乎正在創建一個新的站點和數據庫,我不會這樣做,除非您必須出於任何原因。

我會使用UserProfile爲用戶存儲地址,電話,傳真等附加信息,請查看Membership User Profile API以添加自定義屬性。

另外this article可能有幫助,它有點老,但它應該幫助你,如果需要。