Use Program cs style entry point
This commit is contained in:
@@ -3,6 +3,10 @@ using Electricity.Api;
|
|||||||
using Electricity.Api.Services;
|
using Electricity.Api.Services;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
private static int Main(string[] args)
|
||||||
|
{
|
||||||
var rootCommand = new RootCommand("ElectricityServer is a small REST API to access the electricity log database");
|
var rootCommand = new RootCommand("ElectricityServer is a small REST API to access the electricity log database");
|
||||||
var connectionStringArgument = new Option<string>(
|
var connectionStringArgument = new Option<string>(
|
||||||
name: "--connection-string",
|
name: "--connection-string",
|
||||||
@@ -28,7 +32,7 @@ if (!File.Exists(sqlite3DatabaseFilePath))
|
|||||||
}
|
}
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.Services.AddDbContext<DatabaseContext>((DbContextOptionsBuilder builder) =>
|
builder.Services.AddDbContext<DatabaseContext>((builder) =>
|
||||||
{
|
{
|
||||||
builder.UseSqlite($"Data Source={sqlite3DatabaseFilePath}");
|
builder.UseSqlite($"Data Source={sqlite3DatabaseFilePath}");
|
||||||
});
|
});
|
||||||
@@ -43,6 +47,7 @@ builder.Services.AddCors(options =>
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddControllers()
|
builder.Services.AddControllers()
|
||||||
.AddJsonOptions(config =>
|
.AddJsonOptions(config =>
|
||||||
{
|
{
|
||||||
@@ -69,3 +74,5 @@ app.MapControllers();
|
|||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user