Skip to content

Commit 22172af

Browse files
committed
fixed database connection error in Startup.Database.cs
1 parent ddf6ae3 commit 22172af

3 files changed

Lines changed: 22 additions & 13 deletions

File tree

DisBot.API/DisBot.API.csproj

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,24 @@
3535
</ItemGroup>
3636

3737
<ItemGroup>
38-
<Content Include="..\.dockerignore">
39-
<Link>.dockerignore</Link>
40-
</Content>
38+
<Content Update="appsettings.json">
39+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
40+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
41+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
42+
</Content>
43+
<Content Update="appsettings.Development.json">
44+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
45+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
46+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
47+
</Content>
48+
<Content Include="..\.dockerignore">
49+
<Link>.dockerignore</Link>
50+
</Content>
51+
<Content Update="appsettings.json">
52+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
53+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
54+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
55+
</Content>
4156
</ItemGroup>
42-
57+
4358
</Project>

DisBot.API/Startup/Startup.Database.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ private static async Task InitialiseDatabase(this WebApplicationBuilder builder)
1414
private static async Task LoadDatabase(this WebApplication application)
1515
{
1616
application.Logger.Log(LogLevel.Information, "Loading database...");
17-
18-
Console.WriteLine(application.Configuration.GetSection("Database").Get<DatabaseOptions>().Password);
1917

2018
await using var scope = application.Services.CreateAsyncScope();
21-
var dataContext = scope.ServiceProvider.GetService<DataContext>();
19+
var dataContext = scope.ServiceProvider.GetRequiredService<DataContext>();
2220
application.Logger.Log(LogLevel.Information, "Database initialized.");
2321
await dataContext.Database.MigrateAsync();
2422
application.Logger.Log(LogLevel.Information, "Database migrated.");

DisBot.Shared/DisBot.Shared.csproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,21 @@
44
<TargetFramework>net10.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
<RootNamespace>Shared</RootNamespace>
7+
<RootNamespace>DisBot.Shared</RootNamespace>
88
</PropertyGroup>
99

1010

1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.7"/>
1313
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="10.0.7"/>
1414
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="10.0.7"/>
15-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.7">
16-
<PrivateAssets>all</PrivateAssets>
17-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
18-
</PackageReference>
1915
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.7"/>
2016
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.7">
2117
<PrivateAssets>all</PrivateAssets>
2218
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2319
</PackageReference>
2420
<PackageReference Include="Npgsql" Version="10.0.2"/>
25-
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0-rc.2"/>
21+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0"/>
2622
<PackageReference Include="NetCord" Version="1.0.0-alpha.484"/>
2723
</ItemGroup>
2824

0 commit comments

Comments
 (0)