Answered by:
Working with table with no primary key in Entity Framework

Question
-
Hi All,
I have some tables in the database with no primary key and i want to use these tables in my model but the problem is entity framework consider all non-nullable columns as primary key and thus don't allow me to insert, update or delete data from those tables. Is there any way to get rid of this behavior without making primary key in my database...? Thanx
Friday, November 11, 2011 7:39 AM
Answers
-
Raza,
One workaround could perhaps be to create a new identity column and make that the primary key.
- Marked as answer by Raza Haider Saturday, November 19, 2011 8:25 AM
Thursday, November 17, 2011 8:36 AM
All replies
-
Hi Raza;
The simple answer is no.
Fernando (MCSD)
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".- Proposed as answer by Holger Kreissl Friday, November 11, 2011 2:52 PM
Friday, November 11, 2011 2:35 PM -
Thanx Fernando for you quick reply.
But what should I do if it is nearly impossible to make the primary key in table because it contains some data that conflict with primary key constrain or any other reason...!!
SO such type of system which have 7 or 8 years huuugggeeee data and many tables don't allow to make primary key cant use Entity Framework or other ORM..?
Thursday, November 17, 2011 6:36 AM -
Raza,
One workaround could perhaps be to create a new identity column and make that the primary key.
- Marked as answer by Raza Haider Saturday, November 19, 2011 8:25 AM
Thursday, November 17, 2011 8:36 AM -
Hi Raza;
Doing what Bob suggest is about the only way to CRUD operations in Entity Framework.
Fernando (MCSD)
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".Thursday, November 17, 2011 3:49 PM