And how can I transfer services from Dependancy Injection that are registered in startup.cs in an ASP.NET MVC Core application to classes other than the controller class?
Did I understand correctly that they need to be manually thrown over there, since static methods and variables are an old ideology, and it is no longer supported in ASP.NET MVC Core and IoC is designed to replace it?
UPDATED: I do a database initializer, and I think from where in it to take ApplicationDbContext and UserManager
public static class DbInitializer { public static async void Initialize(ApplicationDbContext db, UserManager<ApplicationUser> userManager,RoleManager<IdentityRole> roleManager) { if(db.Users.Count() == 0 && db.Roles.Count() == 0) { ApplicationUser user1 = new ApplicationUser() { UserName = "Admin", Age = 30 }; await userManager.CreateAsync(user1,"password"); //... } } } Class sturtup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory,ApplicationDbContext db, UserManager<ApplicationUser> userManager, RoleManager<IdentityRole> roleManager) { //... DbInitializer.Initialize(db, userManager, roleManager); } While I am doing this, but I think I can DbInitializer get the necessary services right away from DbInitializer .