如何使用IdentityUser创建一对一或一对一?

时间:2016-07-15 03:04:53

标签: entity-framework mapping asp.net-identity

我有我的班级

public class Person
{
   public string Id {get; set;}
   public string Name {get;set;}
   public int Age {get;set;}

   public virtual Patient {get;set;}
   public virtual User {get;set;}
}
public class Patient 
{
   public string PersonId { get; set; }

   public string Address1 { get; set; }
   public string Address2 { get; set; }
   public string City { get; set; }
   public int Zipcode { get; set; }
   public string State { get; set; }
   public string Country { get; set; }

   public virtual Person Person { get; set; }
}

public class User : IdentityUser
{
}

我想在Patient.csUser.cs Person.cs

中创建一个零或一个映射

对于我使用的Patient课程FluentApi

modelBuilder.Entity<Person>().HasOptional(p => p.Patient).WithRequired(p => p.Person);

对于我的用户班,我该怎么做?

0 个答案:

没有答案