LINQ InsertOnSubmit, DeleteOnSubmit and SubmitChanges not working

By admin - Last updated: Sunday, February 1, 2009 - Save & Share - 2 Comments

I had the same problem with SQLExpress database file.
In one word, I looked at the records from the wrong database. There were actually two versions of the database file.

The mdf file gets copied over to bin\debug\data folder e.g. bin\debug\data\test.mdf after compilation, but I verify the data against the one within solution.
This likely happens when playing around with LINQ within console application or windows form application.

I was viewing the data from data\test.mdf, but the changes of my LINQ made against bin\debug\data\test.mdf

LINQ SQL not saving records diagnostics

LINQ SQL not saving records diagnostics

In order to avoid this,




Posted in LINQ • Tags: , Top Of Page

2 Responses to “LINQ InsertOnSubmit, DeleteOnSubmit and SubmitChanges not working”

Comment from FernandoJS
Time August 19, 2009 at 2:05 pm

Great solutions!

Thanks a Lot!

Comment from Fisshy
Time March 30, 2010 at 10:24 pm

In order to avoid this,

either attach the mdf file to SQL server and change the connection string to point to the SQL server so that you always work with one instance of the database file.
or change the connection string to always point to the physical path of the mdf file.

Or, you just chose “Do not copy” and the connection will point to the DB and not copy it to bin/debug/ every time you run/build your application

Write a comment


Captcha: 8 × = eight