1

There are couple similar questions and answers are like: Better add a primary key...

The question is: Is it possible to insert data in table without primary key using entity framework?

Or I have to use SqlConnection class?

Thank you

1 Answer 1

4

No it is not possible with EF. EF demands that every table has a primary key. If it doesn't have a primary key you must somehow cheat EF so that it believes that some column is primary key - that requires manual modification of EDMX file.

Generally if you have table where no set of columns uniquely identifies records you should not use EF to work with such table because EF always demands unique identification. This is also true for database views.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.