I created a new Entity Framework model from a database. This database has a number of tables, the main table is phones_extensions. The phones_extensions table has columns which are FK's to the other tables - e.g. the restriction_class_id is an FK linking to the phones_restictions_class table where the PK is ID.
The EF4 model automatically generates associations for the tables. Great. Now when I run my application I see not only the numeric restriction_class_id but I also see the textual content pulled in by the association (e.g. phones_restriction_class.name).
But what if I don't want to keep all those extra columns? I right click and delete the restriction_class_id but now I get the error mentioned in the subject of this question.
Is there a way for me to remove the columns so I don't have to mess with them in my applicaiton but still have the associations display correctly?
When you generate your model, un-check the option "Include foreign key columns in the model on the "Choose Your Database Objects" page of the wizard.
I removed a column that related to a foreign table and had the same error message. I deleted every reference that I could find to the foreign key constraint, and still had the message. I updated the model once again, and the error went away.
You can delete obsolete associations (foreign keys) from the Model diagram:
1- Track any Error 111 in the errors pane.
2- Double click the error and it will focus the view on the model diagram with a highlight on the invalid association.
3- Press "Del" on the keyboard.
4- Rebuild the project
I hope this will help some programmer before he gets fired from his job because of this problem ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With