Update EF

This commit is contained in:
2021-12-26 17:06:47 +04:00
parent 5f93d60277
commit 756af71f15
3 changed files with 14 additions and 8 deletions
+9 -5
View File
@@ -6,13 +6,17 @@
<RootNamespace>Kruzya.TelegramBot.Core</RootNamespace> <RootNamespace>Kruzya.TelegramBot.Core</RootNamespace>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Core' " />
<ItemGroup> <ItemGroup>
<PackageReference Include="AleXr64.BotFramework" Version="0.6.3-gea779222d8" /> <PackageReference Include="AleXr64.BotFramework" Version="0.6.3-gea779222d8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.13">
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.2" /> <PrivateAssets>all</PrivateAssets>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.2" /> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="3.1.2" /> </PackageReference>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="5.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.13" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.3" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+3 -2
View File
@@ -32,9 +32,10 @@ namespace Kruzya.TelegramBot.Core
foreach (var module in _core.Modules) services.AddSingleton(module.GetType(), module); foreach (var module in _core.Modules) services.AddSingleton(module.GetType(), module);
// Add database context to DI. // Add database context to DI.
var connectionString = _core.Configuration.GetConnectionString("DefaultConnection");
services.AddDbContext<CoreContext>(ctx => services.AddDbContext<CoreContext>(ctx =>
ctx.UseMySql(_core.Configuration.GetConnectionString("DefaultConnection"))); ctx.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
// Trigger module handlers. // Trigger module handlers.
_core.Modules.ConfigureServices(services); _core.Modules.ConfigureServices(services);
} }
+2 -1
View File
@@ -19,9 +19,10 @@ namespace Kruzya.TelegramBot.RichSiteSummary
public override void ConfigureServices(IServiceCollection services) public override void ConfigureServices(IServiceCollection services)
{ {
var connectionString = Configuration.GetConnectionString("RichSiteSummary");
services.AddDbContext<RichSiteSummaryContext>(options => services.AddDbContext<RichSiteSummaryContext>(options =>
options.UseLazyLoadingProxies() options.UseLazyLoadingProxies()
.UseMySql(Configuration.GetConnectionString("RichSiteSummary"))); .UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
services.AddTelegramBotParameterParser<Feed, DbResolverParameter<Feed, RichSiteSummaryContext>>() services.AddTelegramBotParameterParser<Feed, DbResolverParameter<Feed, RichSiteSummaryContext>>()
.AddTelegramBotParameterParser<Post, DbResolverParameter<Post, RichSiteSummaryContext>>() .AddTelegramBotParameterParser<Post, DbResolverParameter<Post, RichSiteSummaryContext>>()