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;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…