LexWells.Infrastructure/LexWells.Infrastructure.Ent.../DataDependencyInjection.cs

22 lines
648 B
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace LexWells.Infrastructure.EntityFramework;
public static class DataDependencyInjection
{
public static IServiceCollection AddLexWellsDatabase<TContext>(
this IServiceCollection services,
string connectionString) where TContext : DbContext
{
services.AddDbContext<TContext>(options =>
{
options.UseSqlite(connectionString, sqliteOptions =>
{
sqliteOptions.MigrationsAssembly(typeof(TContext).Assembly.FullName);
});
});
return services;
}
}