I am trying to use the Databinding with WPF and Entity Framework.
After adding the data-source to my project, I saved my project in order to see whether everything is fine till what I have done.
but I have a 11 warn/info messages stating :
The table/view 'MyDataBase.TableName' does not have a primary key defined. The key has been inferred and the definition was created as a read-only table/view.
I have 14 Tables where 4 tables has their own primary keys and others tables are referred to each other using foreign keys
What is this issue all about? Kindly help
Every entity in EF must be uniquely identifiable. EF uses database primary keys to define entity keys. While it is possible to work without primary keys to some extend it is definitively not recommended because it leads to many issues. The core issue is mentioned directly in the error - if the table doesn't have primary key, EF marks it as read only because it is not sure that it can uniquely identify record to be updated.
Indeed it is just a warning but you will never be able to use Save functions which in my case makes EF worthless to me for the poorly designed DB I'm stuck working on.
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