public NadekoContext GetDbContext() { var context = new NadekoContext(options); if (context.Database.GetPendingMigrations().Any()) { var mContext = new NadekoContext(migrateOptions); mContext.Database.Migrate(); mContext.SaveChanges(); mContext.Dispose(); } context.Database.SetCommandTimeout(60); context.EnsureSeedData(); //set important sqlite stuffs var conn = context.Database.GetDbConnection(); conn.Open(); context.Database.ExecuteSqlCommand("PRAGMA journal_mode=WAL"); using (var com = conn.CreateCommand()) { com.CommandText = "PRAGMA journal_mode=WAL; PRAGMA synchronous=OFF"; com.ExecuteNonQuery(); } return(context); }
public void Setup() { using (var context = new NadekoContext(options)) { if (context.Database.GetPendingMigrations().Any()) { var mContext = new NadekoContext(migrateOptions); mContext.Database.Migrate(); mContext.SaveChanges(); if (!NadekoContext.IsSqlite) { mContext.Database.ExecuteSqlRaw(@"ALTER TABLE ""DiscordUsers"" ALTER COLUMN ""IsClubAdmin"" SET DEFAULT false; ALTER TABLE ""DiscordUsers"" ALTER COLUMN ""DateAdded"" SET DEFAULT now(); ALTER TABLE ""DiscordUsers"" ALTER COLUMN ""TotalXp"" SET DEFAULT 0; ALTER TABLE ""DiscordUsers"" ALTER COLUMN ""LastLevelUp"" SET DEFAULT now(); ALTER TABLE ""DiscordUsers"" ALTER COLUMN ""LastXpGain"" SET DEFAULT now(); ALTER TABLE ""DiscordUsers"" ALTER COLUMN ""NotifyOnLevelUp"" SET DEFAULT 0; ALTER TABLE ""DiscordUsers"" ALTER COLUMN ""CurrencyAmount"" SET DEFAULT 0; "); } mContext.Dispose(); } if (NadekoContext.IsSqlite) { context.Database.ExecuteSqlRaw("PRAGMA journal_mode=WAL"); } context.EnsureSeedData(); context.SaveChanges(); } }
public NadekoContext GetDbContext() { var context = new NadekoContext(options); context.Database.Migrate(); context.EnsureSeedData(); return(context); }
private NadekoContext GetDbContextInternal() { var context = new NadekoContext(options); context.Database.SetCommandTimeout(60); var conn = context.Database.GetDbConnection(); conn.Open(); return(context); }
public NadekoContext GetDbContext() { var context = new NadekoContext(options); var conn = context.Database.GetDbConnection(); conn.Open(); context.Database.SetCommandTimeout(60); using (var com = conn.CreateCommand()) { com.CommandText = "PRAGMA journal_mode=WAL; PRAGMA synchronous=OFF"; com.ExecuteNonQuery(); } return(context); }
public void Setup() { using (var context = new NadekoContext(options)) { if (context.Database.GetPendingMigrations().Any()) { var mContext = new NadekoContext(migrateOptions); mContext.Database.Migrate(); mContext.SaveChanges(); mContext.Dispose(); } context.EnsureSeedData(); context.SaveChanges(); } }
public void Setup() { using (var context = new NadekoContext(options)) { if (context.Database.GetPendingMigrations().Any()) { var mContext = new NadekoContext(migrateOptions); mContext.Database.Migrate(); mContext.SaveChanges(); mContext.Dispose(); } context.Database.ExecuteSqlRaw("PRAGMA journal_mode=WAL"); context.SaveChanges(); } }