I have an application that when user registers, there will be a new database created for that specific user. My questions: Is this the proper way to create the database dynamically based on EF Core 2.0 Code First and apply migrations?
Assuming I have my context: CustomDbContext, and in the Registration Action I have like this:
[HttpPost]
public async Task<IActionResult> Register(RegisterViewModel model)
{
//register user logic here
using (CustomDbContext ctx = new CustomDbContext())
{
await ctx.Database.EnsureCreatedAsync();
await ctx.Database.MigrateAsync();
}
return RedirectToPage("/Index");
}
Does await ctx.Database.EnsureCreatedAsync(); also apply the migrations? or I do need to run await ctx.Database.MigrateAsync(); to apply them?