LINQ InsertOnSubmit, DeleteOnSubmit and SubmitChanges not working
By admin - Last updated: Sunday, February 1, 2009 - Save & Share - One Comment
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
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.


Comment from FernandoJS
Time August 19, 2009 at 2:05 pm
Great solutions!
Thanks a Lot!