I have a simple sqlite database with two tables. When I manually delete (using SQLite Expert)an entry in table DataSets, the coresponding entry in OneD is deleted as expected. When I delete an entry in DataSets from Entity Framework it does not cause the coresponsing entry in One D to be deleted. There is no error generated.
Any idea why?
Regards
Here is the database definition:
CREATE TABLE [DataSets] (
[DataSetId] INTEGER NOT NULL ON CONFLICT FAIL PRIMARY KEY AUTOINCREMENT,
[Description] TEXT(128));
CREATE TABLE [OneD] (
[OneDId] INTEGER NOT NULL ON CONFLICT FAIL PRIMARY KEY ON CONFLICT ABORT AUTOINCREMENT,
[DataSetId] INTEGER NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT ABORT REFERENCES [DataSets]([DataSetId]) ON DELETE CASCADE,
[StockSheetLength] INTEGER NOT NULL ON CONFLICT FAIL);
Here is how I delete the entry from EF
var dataSets = from ds in context.DataSets select ds;
foreach (var ds in dataSets)
context.DataSets.DeleteObject(ds);
context.SaveChanges();
return true;
From the SQLite documentation: http://www.sqlite.org/foreignkeys.html
Could this be your problem? I don’t know if your Entity Framework turns it on by default with:
Edit: Looking a bit further i stumbled across this: http://nitoprograms.blogspot.com/2010_06_01_archive.html