I'm using DBContext on Entity Framework, using a process like in this tutorial to create the DB.
public class BloggingContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Filename=blog.db");
}
}
and saving using something like:
using (var context = new BloggingContext())
{
context.Add(blog);
await context.SaveChangesAsync();
}
How would I go about setting the Journal Mode to something like WAL?
The Sqlite provider for EF7 support only a small subset off connection string option, therefore you will need to execute some commands manually :
var context = new BloggingContext();
var connection = context.Database.GetDbConnection();
connection.Open();
using (var command = connection.CreateCommand())
{
command.Text= "PRAGMA journal_mode=WAL;";
command.ExecuteNonQuery();
}
You could wrap that in your constructor or in a factory.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.