Entity Framework 4.1 Code First Foreign Key Id's

前端 未结 3 1331
感情败类
感情败类 2021-01-31 05:09

I have two entities referenced one to many. When entity framework created the table it creates two foreign keys, one for the key I have specified with the fluent interface and t

3条回答
  •  抹茶落季
    2021-01-31 06:02

    The default Code First conventions detect your DepartmentId foreign key, since it is, well, conventional. I think you should remove the Fluent definition:

    modelBuilder.Entity()
        .HasRequired(p => p.Department)
        .WithMany()
        .WillCascadeOnDelete(false);
    

提交回复
热议问题