Sequence包含多个匹配元素codefirst

时间:2015-08-17 13:38:19

标签: entity-framework ef-code-first ef-migrations

我在尝试更新关系时遇到此错误(一对一) 流利的api这是我的课程:

    public class Organisation
{
    [Key]
    public int OrganisationId { get; set; }

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

    public virtual ApplicationUser User { get; set; }
    [Required]
    public string ApplicationUserId { get; set; }

    public int? OrganisationDetalisId { get; set; }
    public virtual OrganisationDetalis OrDetalis { get; set; }
    public virtual ICollection<Aeroa> aeroa { get; set; }
    public virtual ICollection<Order> orders { get; set; }

}
  public class OrganisationDetalis
    {
        [Key]
        public int OrganisationDetalisId { get; set; }
        //remove for clear code
        public int OrganisationId { get; set; }
        public virtual Organisation organisation { get; set; }
    }
    public DbSet<Organisation> organisation { get; set; }
       public DbSet<OrganisationDetalis> OrDetalis { get; set; }


    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        modelBuilder.Entity<OrganisationDetalis>()
            .HasKey(o => o.OrganisationId);

        modelBuilder.Entity<Organisation>()
            .HasOptional(ad => ad.OrDetalis).WithRequired(oo => oo.organisation);
    }

但是在更新view nugget控制台时我一直收到错误 问题出在哪里?

0 个答案:

没有答案