using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.Text; namespace FreeSql { public static class DbContextDependencyInjection { public static IServiceCollection AddFreeDbContext(this IServiceCollection services, Action options) where TDbContext : DbContext { services.AddScoped(sp => { var ctx = Activator.CreateInstance(); if (ctx._orm == null) { var builder = new DbContextOptionsBuilder(); options(builder); ctx._orm = builder._fsql; } return ctx; }); return services; } } }