更新时间:2023-02-15 20:13:47
这是错误的:
this.HasRequired(x => x.ContentType)
.WithMany()
.HasForeignKey(x => x.ContentTypeId);
你有反向导航属性,所以你必须在 WithMany
或EF可能会创建两个关系:
You have reverse navigation property so you must use int in WithMany
or EF will probably create two relations:
this.HasRequired(x => x.ContentType)
.WithMany(y => y.ContentTypeColumns)
.HasForeignKey(x => x.ContentTypeId);
Btw。这种映射根本不需要,因为它是通过默认约定自动发现的。
Btw. this mapping should not be needed at all because it is discovered automatically through default conventions.