I have the following model:
public class LogData
{
public Guid ID { get; set; }
public string Name { get; set; }
}
I use Entity Framework Core to save those models to an SQLite database, it works well.
I need to delete from the data (it is dynamic, I can't use objects), so I use the following command:
string command="DELETE FROM LogData WHERE ID IN ('ea53b72a-4ab2-4f88-8f1d-0f96baa7cac7')";
context.Database.ExecuteSQLCommand(command);
According to the SQLite syntax, it is valid.
Unfortunately, as a result I get back 0, so no row was affected.
When I remove the WHERE
condition, it deletes the contents of the table.
I have a guessing that as the key column is a Guid
and it is stored as a BLOB
, the plain SQLite engine can't find it.
So I tried to alter the command to this:
string command="DELETE FROM LogData WHERE HEX(ID) IN ('ea53b72a-4ab2-4f88-8f1d-0f96baa7cac7')";
context.Database.ExecuteSqlCommand(command);
Also tried this:
string command="DELETE FROM AuditLog WHERE HEX(ID) = 'ea53b72a-4ab2-4f88-8f1d-0f96baa7cac7'";
context.Database.ExecuteSqlCommand(command);
This, too:
string command="DELETE FROM AuditLog WHERE ID = 'ea53b72a-4ab2-4f88-8f1d-0f96baa7cac7'";
context.Database.ExecuteSqlCommand(command);
None of those helped.
What should I do about this?