コード例 #1
0
        public static HbrClientDbContext CreateContext(this Context c)
        {
            if (_context == null)
            {
                var context = (HbrClientDbContext)Activator.CreateInstance(typeof(HbrClientDbContext));
                context.Database.EnsureCreated();
                context.Database.Migrate();

                _context = context;
            }

            return(_context);
        }
コード例 #2
0
        public static async Task <HbrClientDbContext> CreateContextAsync(this Context c)
        {
            if (_context == null)
            {
                var context = (HbrClientDbContext)Activator.CreateInstance(typeof(HbrClientDbContext));
                await context.Database.EnsureCreatedAsync();

                await context.Database.MigrateAsync();

                _context = context;
            }

            return(_context);
        }