简体   繁体   中英

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?

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

在此处输入图片说明

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM