AspNetCoreFromZeroToOverkill / GroupManagement

MIT License
29 stars 15 forks source link

installed AspNetCore.AsyncInitialization and created DbInitializer class #25

Closed romanolester closed 5 years ago

romanolester commented 5 years ago

resolving issue #19

romanolester commented 5 years ago

I am really new to ASP.NET Core so please bear with me 😁

joaofbantunes commented 5 years ago

I am really new to ASP.NET Core so please bear with me 😁

No problem, even better! Means besides contributing to a project, you learn some new tech 🙂

romanolester commented 5 years ago

Now in the Program.cs

image

maybe because I inherited IAsyncInitializer interface?

joaofbantunes commented 5 years ago

According to the this, you don't need to do it that way, just change the Main to something similar to:

public static async Task Main(string[] args)
{
    var host = CreateWebHostBuilder(args).Build();
    await host.InitAsync();
    host.Run();
}

The extension will do its thing, and grab the dependencies you registered in the Startup class to init everything.

romanolester commented 5 years ago

oops sorry. my bad

romanolester commented 5 years ago

lastly image how should i properly register the initializer?

joaofbantunes commented 5 years ago

That should be correct. I think it's the generic constraints that are not well defined in the DbInitializer. Should probably be like this:

public class DbInitiliazer<T> : IAsyncInitializer where T : DbContext
romanolester commented 5 years ago

That did it. Thank you.