Craig
Craig

Reputation: 18694

Made column Not Nullable, EF foreign keys errors

I changed a column in a table from NULL to NOT NULL, updated model from database, and am now presented with the following error:

Error 3 Running transformation: Multiplicity conflicts with the referential constraint in Role 'registration' in relationship 'fk_cost_centre_registration'. Because all of the properties in the Dependent Role are non-nullable, multiplicity of the Principal Role must be '1'.

I am unsure how to fix this. What have I done wrong?

I have made many changes to a lot of the navigation properties on one of the tables I have modified, and can't delete it and re-add it, or else I need to rename all the navigation properties and remove a lot that I don't need, with possible regression issues. This is another issue I am facing with EF - as I have changed some navigation properties, removing and readding a table is a massive issue. Yes, I can document the properties I need, but - maybe I am doing something wrong?

Upvotes: 2

Views: 2104

Answers (1)

Giorgi Nakeuri
Giorgi Nakeuri

Reputation: 35780

Simply change multiplicity via properties tab. If Dependent Role is nullable its multiplicity will be 0..1 (Zero or One of ...). If it is not nullable it should be 1 (One of ...). So open your model, find you foreign key and change appropriate multiplicity as shown in the pictures

enter image description here

enter image description here

Upvotes: 4

Related Questions