我正在使用以下类来实现一对多关系:
public class Supplier
{
public Supplier()
{
SupplierId = Guid.NewGuid();
}
public Guid SupplierId { get; set; }
[Required]
public string Name { get; set; }
[Required]
public virtual Address Address { get; set; }
public virtual ICollection<Contact> Contacts { get; set; }
}
public class Contact
{
public Contact()
{
ContactId = Guid.NewGuid();
}
public Guid ContactId { get; set; }
[Required]
public string FirstName { get; set; }
[Required]
public string LastName { get; set; }
[Required] …Run Code Online (Sandbox Code Playgroud)