namespace MyOffice.DbContext;

using Microsoft.Extensions.DependencyInjection;

public record ConnectionConfiguration(string Provider, string ConnectionString);

public static class RepositoryInitializer
{
	/// <summary>
	/// Registers DbContext DI. Migrate/seed runs via <c>DatabaseInitializerHostedService</c>.
	/// <see cref="ConnectionString"/> remains for design-time <see cref="AppDbContextFactory"/>.
	/// </summary>
	public static void Initialize(
		IServiceCollection services,
		ConnectionConfiguration connectionString
	)
	{
		ConnectionString = connectionString;
		services.AddAppDbContext(connectionString);
	}

	public static ConnectionConfiguration ConnectionString { get; internal set; } = null!;
}
