Probably the best place is in Configure
method after UseMvc()
call. That is also the place where you usually apply migrations. You can add as many classes that DI knows as parameter.
For example:
public void Configure(IApplicationBuilder app)
or
public void Configure(IApplicationBuilder app, AppUserManager userManager, IServiceProvider serviceProvider)
or
public void Configure(IApplicationBuilder app, MyDbContext context)
If you want to check this in background (only if you don’t care about result – application should run also if verification fails), check my answer here.
Also this answer may help you.