2

I am building a web application using MVC 3. It has users with different roles and privileges. I am using EF Code First approach for database creation. My model class for user is:

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; }
    }

But for roles and authentication I want to use the default aspnetdb.mdf of App_Data folder. How do I link my Users table with the default Users table of aspnetdb.mdf?

1 Answers1

0

Since it seems like you are creating a new site and DB, I wouldn't go about it this way, unless you have to for whatever reason.

I would use UserProfile to store additional info like address, phone, fax, etc. for the user, take a look at the Membership User Profile API to add the custom properties.

Also this article may help, it's a bit old but it should help you if needed.

Garrett Fogerlie
  • 4,450
  • 3
  • 37
  • 56