public static void Initialize(this IApplicationBuilder builder) { var provider = builder.ApplicationServices; var scopeFactory = provider.GetRequiredService <IServiceScopeFactory>(); using (var scope = scopeFactory.CreateScope()) { using (HopeLineDbContext context = scope.ServiceProvider.GetRequiredService <HopeLineDbContext>()) { } } }
/// <summary> /// Injecting db contexts /// </summary> /// <param name="hopeLineDb"></param> public Repository(HopeLineDbContext hopeLineDb) { _hopeLineDb = hopeLineDb; _entities = _hopeLineDb.Set <T>(); }
/// <summary> /// /// </summary> /// <param name="hopeLineDb"></param> public UserRepository(HopeLineDbContext hopeLineDb) { _hopeLineDb = hopeLineDb; _entities = _hopeLineDb.Set <HopeLineUser>(); }