Пример #1
0
        public EntityFrameworkCoreContext CreateReadOnly()
        {
            var context = new EntityFrameworkCoreContext(_connectionString);

            context.ChangeTracker.AutoDetectChangesEnabled = false;

            return(context);
        }
Пример #2
0
        public static async Task Initialize(EntityFrameworkCoreContext context, bool migrateDoingStartup)
        {
            if (migrateDoingStartup)
            {
                context.Database.Migrate();
            }


            if (!await context.ValidSerialNumbers.AnyAsync())
            {
                var submissions = GenerateRandomSerialNumbers();
                await context.ValidSerialNumbers.AddRangeAsync(submissions);

                await context.SaveChangesAsync();
            }
        }