2

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?

Craig
  • 18,074
  • 38
  • 147
  • 248
  • Did you try deleting the tables in question and then updating? – jamesSampica Jan 16 '15 at 21:37
  • Check this answer I think it will help you: http://stackoverflow.com/questions/8007129/codefirst-ef4-1-mvc-against-legacy-database-multiplicity-conflicts – mybirthname Jan 16 '15 at 21:40
  • It's probably going to take less time to just remake the table and rename stuff than it would be to hunt around the generated EF code and fix things yourself. If you have a lot of properties you have renamed, take a look at [this strategy](http://stackoverflow.com/questions/24958482/how-to-name-foreign-keys-with-database-first-approach/24958870#24958870) to keep your namings when you regenerate models. – jamesSampica Jan 17 '15 at 04:51

1 Answers1

4

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

Giorgi Nakeuri
  • 35,155
  • 8
  • 47
  • 75