public static IServiceCollection AddInfraDependency(this IServiceCollection services) { // Adiciona as principais dependencias do Tnf services.AddTnfKernel(); // Adiciona os registros automaticos de injeção de dependencias do Tnf // ITransientDependency // IScopedDependency // ISingletonDependecy services.AddTnfDefaultConventionalRegistrations(); // Configura o uso do EntityFrameworkCore registrando os contextos que serão // usados pela aplicação services .AddTnfEntityFrameworkCore() .AddTnfDbContext <CustomerDbContext>(config => DbContextConfigurer.Configure(config)) .AddTnfDbContext <EmployeeDbContext>(config => DbContextConfigurer.Configure(config)); // Configura o uso do AutoMappper services.AddTnfAutoMapper(config => { config.AddProfile <CustomerProfile>(); config.AddProfile <EmployeeProfile>(); }); return(services); }
public AppDbContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder <AppDbContext>(); var connectionString = AppConfigurations.Configuration.GetConnectionString("Default"); DbContextConfigurer.Configure(builder, connectionString); return(new AppDbContext(builder.Options)); }
public ProductDbContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder <ProductDbContext>(); var connectionString = MigrationHelper.GetConfiguration().GetConnectionString("DefaultConnection"); DbContextConfigurer.Configure(builder, connectionString); return(new ProductDbContext(builder.Options)); }
public override void ConfigureServices(ServiceConfigurationContext context) { var configuration = context.Services.GetConfiguration(); var connectionString = configuration.GetConnectionString("PostgreSQL"); context.Services.AddAbpDbContext <MyMessengerDbContext>(options => { DbContextConfigurer.Configure(options, connectionString); }); }
public override void PreInitialize() { if (!SkipDbContextRegistration) { Configuration.Modules.AbpEfCore().AddDbContext << %= projectName % > DbContext > (options => { if (options.ExistingConnection != null) { < %= projectName % > DbContextConfigurer.Configure(options.DbContextOptions, options.ExistingConnection); } else {
public static IServiceCollection AddInfraDependency(this IServiceCollection services) { // Configura o uso do EntityFrameworkCore registrando os contextos que serão // usados pela aplicação services .AddTnfEntityFrameworkCore() .AddTnfDbContext <PurchaseOrderContext>(config => DbContextConfigurer.Configure(config)); services.AddTransient <IPurchaseOrderRepository, PurchaseOrderRepository>(); return(services); }
public static void AddProductEntityFramework(this IServiceCollection services, IConfiguration configuration) { services.AddTransient <IUnitOfWork <ProductDbContext>, UnitOfWork <ProductDbContext> >(); services.AddScoped <IProductRepository, ProductRepository>(); services.AddScoped <IProductFamilyRepository, ProductFamilyRepository>(); services.AddScoped <IProductDetailRepository, ProductDetailRepository>(); var connectionString = configuration.GetConnectionString("DefaultConnection"); services.AddDbContext <ProductDbContext>(options => DbContextConfigurer.Configure(options, connectionString)); }
public static void AddInfraDependency(this IServiceCollection services) { // Configura o uso do EntityFrameworkCore registrando os contextos que serão // usados pela aplicação services .AddTnfEntityFrameworkCore() .AddTnfDbContext <CustomerDbContext>(config => DbContextConfigurer.Configure(config)); // Configura o uso do AutoMappper services.AddTnfAutoMapper(config => { config.AddProfile <CustomerProfile>(); }); }
public LegacyDbContext Create(DbContextFactoryOptions options) { var builder = new DbContextOptionsBuilder <LegacyDbContext>(); var assemblyPath = typeof(EntityFrameworkModule).GetAssembly().Location; var assemblyName = typeof(EntityFrameworkModule).GetAssembly().GetName().Name; var assemblyConfig = assemblyPath.Substring(0, assemblyPath.IndexOf(@"\src\", StringComparison.Ordinal) + 5); assemblyConfig = Path.Combine(assemblyConfig, assemblyName); var configuration = AppConfigurations.Get(assemblyConfig); DbContextConfigurer.Configure(builder, configuration.GetConnectionString(AppConsts.ConnectionStringName)); return(new LegacyDbContext(builder.Options)); }
public static IServiceCollection AddInfraDependency(this IServiceCollection services) { // Configura o uso do Dapper registrando os contextos que serão // usados pela aplicação services .AddTnfEntityFrameworkCore() .AddTnfDbContext <PurchaseOrderContext>(config => DbContextConfigurer.Configure(config)) .AddTnfDapper(options => { options.MapperAssemblies.Add(typeof(CustomerMapper).Assembly); options.DbType = DapperDbType.SqlServer; }); services.AddTnfAutoMapper(config => { config.AddProfile <PurchaseOrderProfile>(); }); services.AddTransient <IPurchaseOrderRepository, PurchaseOrderRepository>(); return(services); }