I am using ASP.NET MVC, I created two model classes, User
and Address
. I want to use them on the same view to allow a user to enter all the information on one page. The problem is that ASP.NET MVC allows to pass only one model. What is the best practice to resolve this situation?
public class Address
{
[Key]
public int Id { get; set; }
public int StreetNumber { get; set; }
public string Route { get; set;}
public string City { get; set; }
public string State { get; set; }
public string PostalCode { get; set; }
public string Coutry { get; set; }
public int Adresstype { get; set; }
public int UserId { get; set; }
public virtual User User { get; set; }
}
public class User
{
public User()
{
this.Ads = new HashSet<Ad>();
this.Addresses = new HashSet<Address>();
}
[Key]
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string EmailAddress { get; set; }
public int PhoneNumber { get; set; }
public virtual ICollection<Ad> Ads { get; set; }
public virtual ICollection<Address> Addresses { get; set;}
}