Problems creating a Foreign-Key relationship on Entity Framework

岁酱吖の 提交于 2019-11-30 02:43:20

There is a conflict between your foreign key property in class Dettaglio...

public virtual int IDTEST { get; set; }

...which has a non-nullable type (int) and therefore cannot be optional and your mapping...

this.HasOptional(t => t.TEST_TABLE) //...

...where you want the relationship to be optional.

If you indeed want an optional relationship use a nullable FK property:

public virtual int? IDTEST { get; set; }

Otherwise you must use HasRequired for a required relationship with a non-nullable FK property.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!