Call AddDefaultEfCoreRepositories from AddAbpDbContext

pull/81/head
Halil İbrahim Kalkan 9 years ago
parent c775f3e6d5
commit 69fa91367b

@ -10,7 +10,6 @@ namespace AbpDesk.EntityFrameworkCore
public override void ConfigureServices(IServiceCollection services)
{
services.AddAbpDbContext<AbpDeskDbContext>();
services.AddDefaultEfCoreRepositories<AbpDeskDbContext>();
services.AddAssemblyOf<AbpDeskEntityFrameworkCoreModule>();
}

@ -9,6 +9,7 @@ namespace Microsoft.Extensions.DependencyInjection
//TODO: By default, only create repositories for Aggregate Roots.
//TODO: Move AddDefaultEfCoreRepositories into AddAbpDbContext as optional which will have it's own options
//TODO: Add options to use a provided type as default repository.
//TODO: Register default PK type if available!
public static class AbpEfCoreServiceCollectionExtensions
{
@ -23,10 +24,12 @@ namespace Microsoft.Extensions.DependencyInjection
services.TryAddTransient<TDbContext>();
services.TryAddSingleton(DbContextOptionsFactory.Create<TDbContext>);
services.AddDefaultEfCoreRepositories<TDbContext>();
return services;
}
public static IServiceCollection AddDefaultEfCoreRepositories<TDbContext>(this IServiceCollection services)
private static void AddDefaultEfCoreRepositories<TDbContext>(this IServiceCollection services)
where TDbContext : AbpDbContext<TDbContext>
{
var dbContextType = typeof(TDbContext);
@ -42,8 +45,6 @@ namespace Microsoft.Extensions.DependencyInjection
services.TryAddTransient(repositoryInterfaceType, repositoryImplementationType);
services.TryAddTransient(queryableRepositoryInterfaceType, repositoryImplementationType);
}
return services;
}
}
}

@ -10,7 +10,6 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
public override void ConfigureServices(IServiceCollection services)
{
services.AddAbpDbContext<IdentityDbContext>();
services.AddDefaultEfCoreRepositories<IdentityDbContext>();
services.AddAssemblyOf<AbpIdentityEntityFrameworkCoreModule>();
}
}

Loading…
Cancel
Save