I have 2 models which must be one to one relation
public class Reference
{
public int Id {get;set;}
public string Name {get;set;}
}
public class Matrix
{
public int Id {get;set;}
public string Name {get;set;}
public int ReferenceId {get;set;}
public Reference Reference {get;set; }
}
One Matrix can only have one Reference and One Reference can only have one Matrix
Here is the problem, the Reference can exist without a Matrix, ReferenceId must be unique on the Matrix
How can i do this besides making the foreign key nullable but still unique?