diff --git a/DigitalData.Core.Infrastructure/DependencyInjection.cs b/DigitalData.Core.Infrastructure/DependencyInjection.cs index 0ffdd02..9d656bd 100644 --- a/DigitalData.Core.Infrastructure/DependencyInjection.cs +++ b/DigitalData.Core.Infrastructure/DependencyInjection.cs @@ -8,7 +8,7 @@ public static class DependencyInjection { public static IServiceCollection AddDbRepository(this IServiceCollection services, Func> queryFactory) where TDbContext : DbContext - where TEntity : DbContext + where TEntity : class { return services .AddScoped, DbRepository>() diff --git a/DigitalData.Core.Tests/Infrastructure/DbRepositoryTests.cs b/DigitalData.Core.Tests/Infrastructure/DbRepositoryTests.cs index b3b2ef5..0e2f643 100644 --- a/DigitalData.Core.Tests/Infrastructure/DbRepositoryTests.cs +++ b/DigitalData.Core.Tests/Infrastructure/DbRepositoryTests.cs @@ -1,5 +1,9 @@ namespace DigitalData.Core.Tests.Infrastructure; +using DigitalData.Core.Infrastructure; +using DigitalData.Core.Tests.Mock; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; public class DbRepositoryTests @@ -11,6 +15,10 @@ public class DbRepositoryTests { var builder = Host.CreateApplicationBuilder(); + builder.Services.AddDbContext(opt => opt.UseInMemoryDatabase("MockDB")); + + builder.Services.AddDbRepository(context => context.Users); + _host = builder.Build(); }