C# ASP.NET标识-如何映射一对一或零关系?

C# ASP.NET标识-如何映射一对一或零关系?,c#,asp.net-mvc,entity-framework,entity,identity,C#,Asp.net Mvc,Entity Framework,Entity,Identity,如何首先使用实体框架代码映射以下关系 关系-作者是主体,应用程序用户是从属关系: ApplicationUser是从IdentityUser派生的类。作者可以比用户先创建,因此他们是关系的主体。每个用户都必须与作者相关联,但作者可以不与任何ApplicationUser相关联。我曾尝试使用fluent API和注释来实现这一点,但我不能说ApplicationUser的主键是作者的外键。多谢各位 型号: public class Author { [Key] public s

如何首先使用实体框架代码映射以下关系

关系-作者是主体,应用程序用户是从属关系:

ApplicationUser是从IdentityUser派生的类。作者可以比用户先创建,因此他们是关系的主体。每个用户都必须与作者相关联,但作者可以不与任何ApplicationUser相关联。我曾尝试使用fluent API和注释来实现这一点,但我不能说ApplicationUser的主键是作者的外键。多谢各位

型号:

 public class Author
{
    [Key]
    public string AuthorId { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string Email { get; set; }
    public List<string> AditionalEmails { get; set; }
    public virtual ICollection<PublicationData> Publication { get; set; }

    //User is optional.
    public virtual ApplicationUser User { get; set; }
}



    public partial class ApplicationUser : IdentityUser
{

    public string FirstName { get; set; }
    public string LastName { get; set; }

    public string Affiliation { get; set; }
    public string Position { get; set; }
    public DateTime CreatedOn { get; set; }
    public bool Deleted { get; set; }
    public int CountryCode { get; set; }
    public virtual Country Country { get; set; }
    public virtual ICollection<PublicationData> Publications { get; set; }
    public virtual ICollection<Request> Requests { get; set; }

    //Author is required
    public virtual Author Author { get; set; }
}
公共类作者
{
[关键]
公共字符串AuthorId{get;set;}
公共字符串名{get;set;}
公共字符串LastName{get;set;}
公共字符串电子邮件{get;set;}
公共列表{get;set;}
公共虚拟ICollection发布{get;set;}
//用户是可选的。
公共虚拟应用程序用户{get;set;}
}
公共部分类应用程序用户:IdentityUser
{
公共字符串名{get;set;}
公共字符串LastName{get;set;}
公共字符串从属关系{get;set;}
公共字符串位置{get;set;}
public DateTime CreatedOn{get;set;}
公共bool已删除{get;set;}
公共国际国家代码{get;set;}
公共虚拟国家{get;set;}
公共虚拟ICollection发布{get;set;}
公共虚拟ICollection请求{get;set;}
//作者是必需的
公共虚拟作者{get;set;}
}