trying to merge identity in api
This commit is contained in:
parent
9d4fd1e6c0
commit
5f6095f3ef
39 changed files with 868 additions and 282 deletions
|
@ -15,34 +15,39 @@ namespace SignalRChat
|
|||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
CreateDbIfNotExists(host);
|
||||
host.Run();
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
webBuilder.UseStartup<Startup>().UseUrls("http://localhost:5000");
|
||||
});
|
||||
|
||||
private static void CreateDbIfNotExists(IHost host)
|
||||
{
|
||||
using (var scope = host.Services.CreateScope())
|
||||
{
|
||||
var services = scope.ServiceProvider;
|
||||
try
|
||||
{
|
||||
var context = services.GetRequiredService<MyDbContext>();
|
||||
DbInitializer.Initialize(context);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var logger = services.GetRequiredService<ILogger<Program>>();
|
||||
logger.LogError(ex, "An error occurred creating the DB.");
|
||||
}
|
||||
}
|
||||
}
|
||||
// public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
// Host.CreateDefaultBuilder(args)
|
||||
// .ConfigureWebHostDefaults(webBuilder =>
|
||||
// {
|
||||
// webBuilder.UseStartup<Startup>();
|
||||
// });
|
||||
|
||||
// private static void CreateDbIfNotExists(IHost host)
|
||||
// {
|
||||
// using (var scope = host.Services.CreateScope())
|
||||
// {
|
||||
// var services = scope.ServiceProvider;
|
||||
// try
|
||||
// {
|
||||
// var context = services.GetRequiredService<MyDbContext>();
|
||||
// DbInitializer.Initialize(context);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// var logger = services.GetRequiredService<ILogger<Program>>();
|
||||
// logger.LogError(ex, "An error occurred creating the DB.");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue