LINQ2SQL: SubmitChanges() doesn't do anything?

Dear Linq2SQL,

I'm sorry.  It was a mistake.  I was just doing a simple demo and forgot to define the primary key on a table.  You were so nice to generate my class definitions for me without complaining.  You queried the data and gave it to me without incidence.  You even let me update the object and submit my changes.

But since I forgot to define a primary key for the table, YOU IGNORED ME!  Kind of harsh, in my opinion.  You could have at least given me some kind of an error or something letting me know you had no way to update the table.  During debugging, I asked you for your ChangeSet and you simply told me: 0 Deletes, 0 Creates, 0 Updates.  While that information is correct, it's not very helpful.

Signed,

A developer who would like the last hour backā€¦

Technorati Tags: ,

4 Comments

  • I've done that enough times where it is the first thing I check now.

  • I had that same issue and it was driving me nuts! It wasn't until I tried adding a record that it threw an error and sent me in the right direction...

  • I never had this issue, because my tables queried with Linq always had primary keys. But it is very useful to know Linq2SQL will fail in those cases. Thanks for this entertaining post...

  • I've been there dude, and I feel your pain. The primary key requirement is annoying, and it's only necessary in real life when you need to track changes. So many situations don't require PK's, but LINQ forces it on you.

Comments have been disabled for this content.