Publish from private repository

This commit is contained in:
Gitea Actions
2026-08-01 11:57:50 +00:00
commit 10d87c4ff1
694 changed files with 69367 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
namespace MyOffice.DbContext;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
public class AppDbContextFactory : IDesignTimeDbContextFactory<AppDbContext>
{
public static AppDbContextFactory Instance = new();
public AppDbContext CreateDbContext()
{
return CreateDbContext(null);
}
public AppDbContext CreateDbContext(string[]? args)
{
var connection = RepositoryInitializer.ConnectionString;
if (connection is null)
{
connection = new ConnectionConfiguration(
args?[0] ?? "npgsql",
args?[1] ?? string.Empty);
}
var builder = new DbContextOptionsBuilder<AppDbContext>();
DbContextServiceCollectionExtensions.ConfigureDbContextOptions(builder, connection);
if (!Enum.TryParse<AppDbContextProvidersEnum>(connection?.Provider ?? args?[0] ?? "", ignoreCase: true, out var providerEnum))
throw new InvalidOperationException($"No such provider: [{connection?.Provider}]");
var db = new AppDbContext(providerEnum, builder.Options);
db.ChangeTracker.AutoDetectChangesEnabled = false;
db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
return db;
}
}