Reputation: 1081
I'm getting a multiplicity constraint violation in my entity model.
On my entity model I have two relationship properties:
SubstanceTypeMixConstituents
- Multiplicity * (Many)
Category
- Multiplicity: 1 (One)
- Foreign key, not null
How do I find what causing the problem and resolve this issue?
System.InvalidOperationException: A relationship multiplicity constraint violation occurred: An EntityReference expected at least one related object, but the query returned no related objects from the data store.
at System.Data.Objects.DataClasses.EntityReference`1.Load(MergeOption mergeOption)
at System.Data.Objects.DataClasses.RelatedEnd.DeferredLoad()
at System.Data.Objects.Internal.LazyLoadBehavior.LoadProperty[TItem](TItem propertyValue, String relationshipName, String targetRoleName, Boolean mustBeNull, Object wrapperObject)
at System.Data.Objects.Internal.LazyLoadBehavior.<>c__DisplayClass7`2.<GetInterceptorDelegate>b__2(TProxy proxy, TItem item)
at System.Data.Entity.DynamicProxies.SubstanceType_BEE32ACA75386E981F7CA3F6A3C565BC1D8ADACA228C603A2EACC918DCDCBA30.get_Category()
Upvotes: 3
Views: 5237
Reputation: 17752
As far as I understand, you have two entities - Category
and SubstanceTypeMixConstituent
which have a One-to-many
relationship - a Category
can have multiple SubstanceTypeMixConstituents
, but a SubstanceTypeMixConstituent
can have (and must have) only one Category
(correct me if I am wrong). The error message you get means exactly what it says - you are either trying to save a Category
with an empty collection of SubstanceTypeMixConstituents
, or a SubstanceTypeMixConstituent
without a Category
.
Upvotes: 2