Пример #1
0
        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);
        }
Пример #2
0
 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();
     }
 }
Пример #3
0
        public NadekoContext GetDbContext()
        {
            var context = new NadekoContext(options);

            context.Database.Migrate();
            context.EnsureSeedData();
            return(context);
        }
Пример #4
0
        private NadekoContext GetDbContextInternal()
        {
            var context = new NadekoContext(options);

            context.Database.SetCommandTimeout(60);
            var conn = context.Database.GetDbConnection();

            conn.Open();
            return(context);
        }
Пример #5
0
        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);
        }
Пример #6
0
 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();
     }
 }
Пример #7
0
 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();
     }
 }