Hello,
using EF 4.3 Code First
I want to design two optional relations between two classes:
After reading Entity Framework 4.1 InverseProperty Attribute and ForeignKey I designed my classes:
<Table("Person")>
public class Person
<InverseProperty("QuestioningPerson")>
Public Overridable Property QuestionnaireResponseQuestioningList As ICollection(Of QuestionnaireResponse)
<InverseProperty("AnsweringPerson")>
Public Overridable Property QuestionnaireResponseAnsweringList As ICollection(Of QuestionnaireResponse)
end class
public class QuestionnaireResponse
<ForeignKey("QuestioningPerson")>
Public Property QuestioningPerson_Id As Guid
<ForeignKey("AnsweringPerson")>
Public Property AnsweringPerson_Id As Guid
<InverseProperty("QuestionnaireResponseQuestioningList")>
Public Overridable Property QuestioningPerson As Person
<InverseProperty("QuestionnaireResponseAnsweringList")>
Public Overridable Property AnsweringPerson As Person
end class
I received NullReferenceExceptio...
reading
Using InverseProperty on self-referencing entity in 4.3
I tried with one of that relations removing the InverseProperty Annotations...Building was possible --> creating a required relation.
Should i rather use FluentAPI?