I am looking for a way to add manual raw SQL call to standard AppDbContext interaction. Say I have following code:
Message m = new Message
{
Title = message.Title,
Body = message.Body,
Date = DateTime.Now,
Foo = "foo"
};
_context.Messages.Add(m);
// Add some manual UPDATE SQL here, like:
// UPDATE SomeOtherTable SET Foo = 'Something' WHERE SomeComplex = 'Condition'
_context.SaveChanges();
The most important thing is to make that manual SQL part of command / transaction that gets created and executed as part of SaveChanges. If there is a way to inject my modification into SQL generated by SaveChanges - that's what I'm looking for.
SaveChangeswithin transaction.context.Database.BeginTransaction()and thentransaction.Commit()