I have a model that has two foreign keys (as well as a primary key). I want to set the two fks unique together (meaning there can't be two columns with both having the same two fk values).
I've tried everything but I keep getting: "The type 'Model.MyType' must be a non-nullable value type in order to use it as a parameter 'T'". This error is in the Property function:
Property (o => o.MyType).HasColumnAnnotation (IndexAnnotation.AnnotationName,
new IndexAnnotation (new IndexAttribute ("UX_MyConstraint", 1) {IsUnique = true}));
(And another one with 2).
I prefer a fluent api solution but data annotations are fine too.
(C# entity framework 6.1 code first)
Thanks!