I'm using SQLiteNetExtensions to create a foreign key from one table to another so I can delete on cascade. I followed the documentation on: https://bitbucket.org/twincoders/sqlite-net-extensions,
but when I delete a record on my Missions Table, the records on my Locations Table that reference that primary key don't get deleted,
am I missing something?
These are my tables:
using SQLiteNetExtensions.Attributes;
public class Locations
{
[PrimaryKey, AutoIncrement]
public int locationId { get; set; }
[ForeignKey(typeof(Missions))]
public int missionId { get; set; }
}
and :
using SQLiteNetExtensions.Attributes;
public class Missions
{
[PrimaryKey, AutoIncrement]
public int missionId { get; set; }
public String missionName { get; set; }
[OneToMany(CascadeOperations = CascadeOperation.CascadeDelete)]
public List<Locations> Locations { get; set; }
}
Also this is the delete method used to delete records from the missions table:
public Task<int> DeleteMyMissionAsync(Missions myMission)
{
return database.DeleteAsync(myMission);
}
Is there any way to check what this attributes from the SQLite extension are doing? my code compiles and runs, so I don't know where the mistake is.
I tried also adding "using SQLiteNetExtensionsAsync" but this didn't make any difference.
EDIT: Changed my delete method to :
public Task DeleteMyMissionAsync(Models.MyCreatedMissions myMission)
{
return database.DeleteAsync(myMission, recursive: true);
}
it runs but when I delete a record in the Missions table referenced by my Locations table, it only deletes that record and all the records in the Locations table that reference that record still exist.
any ideas?