I have a local, SQL Server Compact database in an application I am creating. I generated a .dbml file I can use for LINQ-to-SQL purposes using the SqlMetal.exe tool, which worked fine – I now have the table objects for use in my application.
I have a strange issue though. Even after calling SubmitChanges() on my DataContext, the data never commits. But strangely, after adding the rows, these rows do appear in the table object on the datacontext, but not in the table. What shocked me is even after stopping and starting my application, these rows still existed in the DataContext – but after a few minutes they seem to disappear.
Have I configured this correctly? Are there any more steps I need to do after using SqlMetal to allow the LINQ to commit changes?
I am assuming that you linked to the dbml file using the default properties. This means that, each time you start a debug session, the file will be copied into your output directory and changes made to it will only be seen for that session (i.e., “Copy -> Always”).
If you want the changes to persist then right click the file -> properties -> Copy Never. By default the IDE assumes that you don’t want to modify the original database, only a copy for debugging purposes.