The problem arises at the end of the guide, when making a POST type call, on SaveChangesAsync() I get this error: "SQLite Error 6: database table is locked"
Below is the portion of sample code in the guide.
[HttpPost]
public async Task InsertComment(BlogComment comment)
{
using IEfCoreScope<BlogContext> scope = _efCoreScopeProvider.CreateScope();
await scope.ExecuteWithContextAsync<Task>(async db =>
{
db.BlogComments.Add(comment);
await db.SaveChangesAsync();
});
scope.Complete();
}
I was running into this same issue and I've been able to work past it using a non-simplified using statement. I'm not sure why it works, but I have seen this in Core with other methods where using the simplified using throws unexpected errors.
But anyway this code should work for you:
[HttpPost]
public async Task InsertComment(BlogComment comment)
{
using IEfCoreScope<BlogContext> scope = _efCoreScopeProvider.CreateScope())
{
await scope.ExecuteWithContextAsync<Task>(async db =>
{
db.BlogComments.Add(comment);
await db.SaveChangesAsync();
});
scope.Complete();
}
}
SQLite Error 6: database table is locked
Hello everyone! In project i need to create a custom tables, so i followed this guide. https://docs.umbraco.com/umbraco-cms/tutorials/getting-started-with-entity-framework-core
The problem arises at the end of the guide, when making a POST type call, on SaveChangesAsync() I get this error: "SQLite Error 6: database table is locked"
Below is the portion of sample code in the guide.
Thanks.
Hey Diego,
I was running into this same issue and I've been able to work past it using a non-simplified using statement. I'm not sure why it works, but I have seen this in Core with other methods where using the simplified using throws unexpected errors. But anyway this code should work for you:
Hope that helps!
--Mark
Thank you very much Mark!
Anytime, glad it helped!
Did you find any solution about this issue?
I'd like to know the answer to that question as well.
Could it be that the problem is the usage of lock statements and not SemaphoreSlim.WaitAsync() and .Release() ?
is working on a reply...