コード例 #1
0
        public MainDatabase CreateDbContext()
        {
            var builder = new DbContextOptionsBuilder <MainDatabase>();

            builder.UseSqlite(this.connection);

            var context = new TestMainDatabase(builder.Options);

            try
            {
                context.Database.EnsureCreated();
            }
            catch
            {
                context.Dispose();
                throw;
            }

            return(context);
        }
コード例 #2
0
        public MainDatabase CreateDbContext()
        {
            var builder = new DbContextOptionsBuilder <MainDatabase>();

            builder.EnableDetailedErrors();
            builder.EnableSensitiveDataLogging();
            builder.UseSqlite(this.connection);
            builder.UseLoggerFactory(this.logger);

            var context = new TestMainDatabase(builder.Options);

            try
            {
                context.Database.EnsureCreated();
            }
            catch
            {
                context.Dispose();
                throw;
            }

            return(context);
        }