Created
April 15, 2021 19:42
-
-
Save Orbis25/f15b727f9b7eedb6f0dce463b10522bd to your computer and use it in GitHub Desktop.
get dbcontext instance in middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//IApplicationBuilder app; | |
using var appScoped = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope(); | |
ApplicationDbContext _context = appScoped.ServiceProvider.GetService<ApplicationDbContext>(); | |
UserManager<ApplicationUser> _userManager = appScoped.ServiceProvider.GetService<UserManager<ApplicationUser>>(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment