2016-04-15 9 views
1

in this tutorialのようなプロセスを使用して、Entity FrameworkでDBContextを使用してDBを作成しています。SQLite for Entity Frameworkコアコードファーストでのジャーナルモードの設定

public class BloggingContext : DbContext 
{ 
    public DbSet<Blog> Blogs { get; set; } 

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 
    { 
     optionsBuilder.UseSqlite("Filename=blog.db"); 
    } 
} 

とのようなもの使用して保存:どのように私はWALのようなものにジャーナルモードの設定については行くだろう

using (var context = new BloggingContext()) 
{ 
    context.Add(blog); 
    await context.SaveChangesAsync(); 
} 

を?

答えて

2

接続文字列オプションをオフ小さなサブセットのみEF7をサポートするためのSqliteを提供、したがって、あなたは手動でいくつかのコマンドを実行する必要があります:あなたは、あなたのコンストラクタや工場でそれをラップすることができ

var context = new BloggingContext(); 
var connection = context.Database.GetDbConnection(); 
connection.Open(); 
using (var command = connection.CreateCommand()) 
{ 
    command.Text= "PRAGMA journal_mode=WAL;"; 
    command.ExecuteNonQuery(); 
} 

関連postおよびother one

関連する問題