// This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

            /*Configurando el servicio de base de datos en memoria*/
            // services.AddDbContext<EscuelaContext>(
            //     options => options.UseInMemoryDatabase(databaseName:"tasteDB")
            // );


            /*Configurando el servicio de base de datos en SQL Server*/
            string connString =
                ConfigurationExtensions.GetConnectionString
                    (this.Configuration, "DefaultConnectionString");


            services.AddDbContext <EscuelaContext>(
                options => options.UseSqlServer(connString)
                );
            // services.AddTransient<IProductRepo, ProductRepo>();

            services.AddMvc(option => option.EnableEndpointRouting = false);
        }
        public static IServiceCollection RegisterServices(this IServiceCollection services, IConfiguration Configuration)
        {
            services.AddDbContext <AppDbContext>(options => options.UseSqlServer(ConfigurationExtensions.GetConnectionString(Configuration, "DefaultConnection"), x => x.MigrationsAssembly("Planner.Data")));
            services.AddTransient <IUnitOfWork, UnitOfWork>();
            services.AddSingleton <IUserRepository, UserRepository>();
            services.AddSingleton <INdrRepository, NdrRepository>();
            services.AddSingleton <IDayEntryLoadRepository, DayEntryLoadRepository>();
            services.AddSingleton <INMBDRepository, NMBDRepository>();
            services.AddSingleton <IRoleRepository, RoleRepository>();
            services.AddSingleton <IIndivPlanFieldsRepository, IndivPlanFieldRepository>();
            services.AddSingleton <IIndivPlanFieldsValueRepository, IndivPlanFieldsValueRepository>();

            services.AddSingleton <IPublicationRepositpry, PublicationRepositpry>();
            services.AddTransient <IUserService, UserService>();
            services.AddTransient <ITokenService, TokenService>();
            services.AddTransient <IServiceFactory, ServiceFactory>();
            services.AddTransient <IDistributionService, DistributionService>();
            services.AddTransient <ISecurityService, SecurityService>();
            services.AddTransient <INdrService, NdrService>();
            services.AddTransient <IPublicationService, PublicationService>();
            services.AddTransient <IIndividualPlanService, IndividualPlanService>();


            services.AddAutoMapper(null, AppDomain.CurrentDomain.GetAssemblies());

            return(services);
        }
예제 #3
0
        public static string GetConnectionString(string name)
        {
            var configuration    = GetConfiguration();
            var connectionString = ConfigurationExtensions.GetConnectionString(configuration, name);

            return(connectionString);
        }
예제 #4
0
            public void AnArgumentNullExceptionIsThrown()
            {
                var exception = Assert.Throws <ArgumentNullException>(
                    () => ConfigurationExtensions.ForMsSql2005Connection(null, "TestConnection", "Data Source=.", "System.Data.SqlClient"));

                Assert.Equal("configureConnection", exception.ParamName);
            }
예제 #5
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            var connString = ConfigurationExtensions.GetConnectionString(this.Configuration, "SQLSERVERDB");

            signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(Configuration["Keys:UserAuthSecretKey"]));


            tokenValidationParameters = new TokenValidationParameters
            {
                ValidateIssuerSigningKey = true,
                IssuerSigningKey         = signingKey,
                ValidateIssuer           = true,
                ValidIssuer      = Configuration["Digiturk:ValidateKey"],
                ValidateAudience = true,
                ValidAudience    = Configuration["Digiturk:ValidateKey"],
                ValidateLifetime = true,
            };



            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            SeedDatabase.Initialize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider);

            app.UseAuthentication();
            app.UseHttpsRedirection();
            app.UseMvc();
        }
예제 #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc()
            .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
            services.AddSingleton <IConfigurationRoot>(Configuration);

            var dbType = ConfigurationExtensions.GetConnectionString(Configuration, "WfDBConnectionType");
            var sqlConnectionString = ConfigurationExtensions.GetConnectionString(Configuration, "WfDBConnectionString");

            NETBPMFlow.Data.ConnectionString.DbType = dbType;
            NETBPMFlow.Data.ConnectionString.Value  = sqlConnectionString;

            services.AddMvcCore()
            .AddJsonFormatters();

            services.AddCors(options =>
            {
                options.AddPolicy("AllowAll", p => p.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials());
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info {
                    Title = "My API", Version = "v1"
                });
                c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
            });

            services.AddConsulService(Configuration);
        }
예제 #7
0
            public void AnArgumentNullExceptionIsThrown()
            {
                var exception = Assert.Throws <ArgumentNullException>(
                    () => ConfigurationExtensions.ForPostgreSqlConnection(null, "TestConnection", "Data Source=.", "Npgsql"));

                Assert.Equal("configureConnection", exception.ParamName);
            }
예제 #8
0
        public void ConfigureServices(IServiceCollection services)
        {
            var conString = ConfigurationExtensions.GetConnectionString(this.Configuration, "postgres");

            services.AddDbContext <ScotgovCovidStatsContext>(opts => opts.UseNpgsql(conString));
            services.AddGraphQL(
                SchemaBuilder.New()
                .AddQueryType <Query>()
                .Create(),
                new QueryExecutionOptions {
                ForceSerialExecution = true
            });

            if (Configuration.GetValue <bool>("EnableCors"))
            {
                _logger.Debug("Enabling CORS policy");
                services.AddCors(o => o.AddPolicy(CorsPolicyName, builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader()
                    .AllowCredentials();
                }));
            }
        }
예제 #9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews()
            .AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);

            services.AddMvc(options =>
            {
                options.Filters.Add(new ValidationFilter());
            })
            .AddFluentValidation(options =>
            {
                options.RegisterValidatorsFromAssemblyContaining <Startup>();
            });

            if (CurrentEnvironment.IsEnvironment("Testing"))
            {
                services.AddDbContext <MyDbContext>(options =>
                                                    options.UseInMemoryDatabase("TestingDB").UseLazyLoadingProxies());
            }
            else
            {
                services.AddDbContext <MyDbContext>(options =>
                                                    options.UseMySql(ConfigurationExtensions.GetConnectionString(Configuration, "MyDbContextConnectionString")).UseLazyLoadingProxies());
            }

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });
        }
예제 #10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            //Base de datos en memoria

            /* services.AddDbContext<EscuelaContext>(
             *  options => options.UseInMemoryDatabase(databaseName:"testDB" )
             * );*/


            string connString = ConfigurationExtensions.GetConnectionString(this.Configuration, "DefaultConnectionString");

            services.AddDbContext <EscuelaContext>(
                options => options.UseSqlServer(connString)
                );
        }
예제 #11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            /* agrego un nuevo servicio de base de datos a mi aplicacion
             * mapeamos un EscuelaContext en un servicio
             * con esto ya puedo agregar una base de datos en memoria, la llame testDB (es para pruebas)
             *
             *
             * services.AddDbContext<PicashDbContext>(options => options.UseInMemoryDatabase(databaseName: "testDB"));
             *
             * /* para trabajar con db *****************************************************/

            string connString = ConfigurationExtensions.GetConnectionString(Configuration, "DefaultConnectionString");

            services.AddDbContext <PicashDbContext>(options => options.UseSqlServer(connString));

            /* para trabajar con db *********************************************************/
        }
예제 #12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            string conString = ConfigurationExtensions
                               .GetConnectionString(this.Configuration, "DefaultConnection");

            services.AddDbContext <MantenimientoDbContext>
                (options => options.UseSqlServer(conString));

            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MappingProfile());
            });

            IMapper mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);

            services.AddTransient <ResidentRepository, ResidentRepository>();

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info
                {
                    Version        = "v1",
                    Title          = "My First API",
                    Description    = "My First ASP.NET Core 2.0 Web API",
                    TermsOfService = "None",
                    Contact        = new Contact()
                    {
                        Name = "Neel Bhatt", Email = "*****@*****.**", Url = "https://neelbhatt40.wordpress.com/"
                    }
                });
            });
        }
예제 #13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddHealthChecks()
            .AddCheck("sql", () => {
                ///Perform your health check here. This sample considers the service unhealthy
                ///if it can't connect to the configured default database
                /// by using  app.UseHealthChecks("/Health");
                /// You configure the health check path
                /// Use that path when configuring the load balancer health probes

                var connectionString = ConfigurationExtensions.GetConnectionString(this.Configuration, "DefaultConnection");

                using (var connection = new SqlConnection(connectionString))
                {
                    try
                    {
                        connection.Open();
                    }
                    catch (SqlException)
                    {
                        return(HealthCheckResult.Unhealthy());
                    }
                }

                return(HealthCheckResult.Healthy());
            });
        }
예제 #14
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     // Add framework services.
     services.AddMvc();
     ConnectionStringBeta.Value  = ConfigurationExtensions.GetConnectionString(Configuration, "WfDBConnectionString");
     ConnectionStringBeta.DbType = ConfigurationExtensions.GetConnectionString(Configuration, "WfDBConnectionType");
 }
예제 #15
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = Microsoft.AspNetCore.Http.SameSiteMode.None;
            }
                                                     );

            services.AddControllersWithViews();

            // Conexion  a DbInMemory
            // services.AddDbContext<ClienteContext>(
            // // utilizamos un delegado para confgurar el servicio de la datanabe in memory
            // options => options.UseInMemoryDatabase(databaseName:"testDB")
            // );

            // Conexion  a Db in Azure
            string connString = ConfigurationExtensions.GetConnectionString(this.Configuration, "DefaultConnectionsString");

            services.AddDbContext <ClienteContext>(
                // utilizamos un delegado para configurar
                // el servicio de la DB in Azure pasandole por parametro la cadena de conexion
                options => options.UseSqlServer(connString)
                );
        }
예제 #16
0
        protected override void OnConfiguring(DbContextOptionsBuilder options)
        {
            if (!options.IsConfigured)
            {
                if (InMemory)
                {
                    // If configure object is null use DB in Memory
                    options.UseInMemoryDatabase("JobBoardDB");
                    return;
                }
                if (Configuration != null)
                {
                    // Configure DB Context for SQL Server
                    string connectionString = ConfigurationExtensions.GetConnectionString(this.Configuration, "JobBoardConnectionString");
                    options.UseSqlServer(connectionString);
                }
                else
                {
                    if (ConnectionString == String.Empty)
                    {
                        IConfigurationBuilder builder = new ConfigurationBuilder();
                        builder.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true);

                        // Configuration for SQL Server, but It can be any database  supported for EF
                        var root = builder.Build();
                        ConnectionString = root.GetConnectionString("JobBoardConnectionString");
                    }
                    options.UseSqlServer(ConnectionString);
                }
            }
        }
예제 #17
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        /// <param name="loggerFactory"></param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
            loggerFactory.AddContext(LogLevel.Information, Configuration.GetConnectionString("MentorsAcademyLogDatabase"));

            var jwtAppSettingOptions = Configuration.GetSection(nameof(JwtIssuerOptions));
            var connectionString     = ConfigurationExtensions.GetConnectionString(this.Configuration, "MentorsAcademyLogDatabase");

            if (!String.IsNullOrEmpty(connectionString))
            {
                app.UseLoggingMiddleware(new LoggingMiddlewareOptions {
                    _connectionString = connectionString
                });
            }

            app.UseAuthentication();

            app.UseMvc();

            app.UseDefaultFiles();
            app.UseStaticFiles();
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Academy.Mentors API V1");
                c.DocExpansion("none");
            });
        }
예제 #18
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });
            services.AddMvc()
            .AddJsonOptions(opt => opt.JsonSerializerOptions.PropertyNamingPolicy = null);

            //跨域
            services.AddCors(options =>
            {
                // Policy 名称是自定义的,可以自己改
                options.AddPolicy("AllowAll", policy =>
                {
                    //设定允许跨域访问的地址,有多个的话用 `,` 隔开
                    policy
                    .WithOrigins("http://localhost:8080")           //这里对应前端站点地址
                    .AllowAnyMethod()
                    .AllowAnyHeader()
                    .AllowCredentials();
                });
            });
            var dbType = ConfigurationExtensions.GetConnectionString(Configuration, "WfDBConnectionType");
            var sqlConnectionString = ConfigurationExtensions.GetConnectionString(Configuration, "WfDBConnectionString");

            Slickflow.Data.DBTypeExtenstions.InitConnectionString(dbType, sqlConnectionString);
        }
        /// <summary>
        /// 添加Jwt认证
        /// </summary>
        /// <param name="services"></param>
        /// <param name="env"></param>
        public static IServiceCollection AddJwtAuth(this IServiceCollection services, IHostingEnvironment env)
        {
            var jwtOptions = ConfigurationExtensions.Get <JwtOptions>("Jwt", env.EnvironmentName);

            services.AddSingleton(jwtOptions);
            services.TryAddSingleton(typeof(ILoginHandler), typeof(JwtLoginHandler));
            services.TryAddSingleton(typeof(LoginInfo));

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,
                    ValidIssuer      = jwtOptions.Issuer,
                    ValidAudience    = jwtOptions.Audience,
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtOptions.Key))
                };
            });

            return(services);
        }
        public NormasController(ILogger <NormasController> logger, IConfiguration configuration) : base(logger)
        {
            string conString = ConfigurationExtensions
                               .GetConnectionString(configuration, "TCLEGISConnectionString");

            _serviceBLL = new ServiceBLL(conString);
        }
예제 #21
0
            public void AnArgumentNullExceptionIsThrown()
            {
                var exception = Assert.Throws <ArgumentNullException>(
                    () => ConfigurationExtensions.ForFirebirdConnection(null, "TestConnection"));

                Assert.Equal("configureConnection", exception.ParamName);
            }
예제 #22
0
        static void Main(string[] args)
        {
            IConfiguration config = new ConfigurationBuilder()
                                    .SetBasePath(Directory.GetCurrentDirectory())
                                    .AddJsonFile("appsettings.json", false, true)
                                    .Build();
            var services = new ServiceCollection();

            services.AddTransient <MongoDatabaseContext>();
            services.AddTransient(typeof(IDatabaseContext), InitializeDatabaseContext.ResolveDatabaseContextType());
            services.AddTransient <ExternalUsersSync>();
            services.AddDbContext <DatabaseContext>(options =>
            {
                string conString =
                    ConfigurationExtensions
                    .GetConnectionString(config, "DefaultConnection");

                Console.WriteLine(conString);

                options.UseSqlServer(conString);
            }, ServiceLifetime.Scoped);

            services.AddLogging(loggingBuilder =>
            {
                loggingBuilder.AddSeq(config.GetSection("Seq"));
            });

            services.AddQuartz();
            var serviceProvider = services.BuildServiceProvider();

            Task.Run(async() => await StartQuartz.Start(serviceProvider));
            Console.ReadLine();
        }
예제 #23
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });
            services.AddDbContext <AppDataContext>(options => options.UseSqlServer(ConfigurationExtensions.GetConnectionString(this.Configuration, "DefaultConnection")));
            services.AddIdentity <IdentityUser, IdentityRole>().AddEntityFrameworkStores <AppDataContext>();
            services.Configure <IdentityOptions>(options =>
            {
                // Default Password settings.
                options.Password.RequireDigit           = true;
                options.Password.RequireLowercase       = false;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = false;
                options.Password.RequiredLength         = 6;
                options.Password.RequiredUniqueChars    = 1;
            });
            services.AddScoped(typeof(IRepository <>), typeof(Repository <>));
            services.AddScoped <IAssignmentRepository, AssigmentRepository>();
            services.AddScoped <IAssigmentStatusRepository, AssigmentStatusRepository>();
            services.AddScoped <ICommentRepository, CommentRepository>();
            services.AddScoped <ICompanyRepository, CompanyRepository>();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
예제 #24
0
        public static IServiceCollection RegisterServices(this IServiceCollection services, IConfiguration configuration)
        {
            var declarations = Business.Authorize.InitializeServices.Register()
                               .Concat(Business.Account.InitializeServices.Register())
                               .ToList();

            services.AddSingleton <ICryptography, CryptographyService>();

            foreach (var declaration in declarations)
            {
                services.AddTransient(declaration.DeclarationType, declaration.InstanceType);
            }

            services.AddMediatR();
            services.AddHttpContextAccessor();
            services.AddDbContext <ApplicationDbContext>(options =>
            {
                string conString =
                    ConfigurationExtensions
                    .GetConnectionString(configuration, "DefaultConnection");

                options.UseSqlServer(conString);
            }, ServiceLifetime.Scoped);

            return(services);
        }
예제 #25
0
        /// <summary>
        /// Get the KPI_config table from m3metric DB
        /// </summary>
        /// <returns></returns>
        private DataTable KPiConfigfromM3metricDb()
        {
            int       kpiNameId;
            int       kpiTargetTableId;
            int       kpiTargetColumnId;
            DataTable kpiConfig        = new DataTable();
            string    ConnectionString = ConfigurationExtensions.GetConnectionString(_Configuration, DomainConstants.MeridianConnection);

            using (SqlConnection sqlConn = new SqlConnection(ConnectionString))
            {
                using (SqlCommand sqlCmd = new SqlCommand())
                {
                    sqlCmd.Connection  = sqlConn;
                    sqlCmd.CommandType = CommandType.Text;
                    sqlCmd.CommandText = "Select * from kpi_config";
                    sqlConn.Open();
                    SqlDataReader kpi = sqlCmd.ExecuteReader();
                    kpiConfig.Load(kpi);
                    DataColumnCollection columns = kpiConfig.Columns;
                    kpiNameId         = columns["kpi_name"].Ordinal;
                    kpiTargetTableId  = columns["kpi_target_table"].Ordinal;
                    kpiTargetColumnId = columns["kpi_target_column"].Ordinal;
                    sqlConn.Close();
                }
            }
            return(kpiConfig);
        }
예제 #26
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddScoped <IProductsServices, ProductService>();
            services.AddScoped <ICategoriesServices, CategoriesService>();



            string conString =
                ConfigurationExtensions
                .GetConnectionString(this.Configuration, "WebShopConnection");

            services.AddDbContext <WebShopLibrary.ShopDataStorageContext>(options =>
                                                                          options.UseSqlServer(conString));//Configuration.GetConnectionString("WebShopConnection")));

            Boolean result = checkConnectionString(conString);
        }
예제 #27
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            // Context to handle in Memory database
            //services.AddDbContext<AcademyContext>(
            // stablishing what database we are using
            //        options => options.UseInMemoryDatabase(databaseName: "testInMemDB")
            //    );

            // to connect sqlServer
            var connString = ConfigurationExtensions.GetConnectionString(this.Configuration,
                                                                         "DefaultConnection");

            services.AddDbContext <AcademyContext>(
                // stablishing what database we are using
                options => options.UseSqlServer(connString)
                );
        }
예제 #28
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            //Aplicamos compatibilidad para versiones anteriores.
            services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_3_0);

            //Inyectamos la conexión a la base de datos temporal

            /*services.AddDbContext<EscuelaContext>(
             *  options => options.UseInMemoryDatabase(databaseName: "dbtemp")
             * );*/

            //Inyectamos la conexión a la base de datos SQL Server
            string connString = ConfigurationExtensions.GetConnectionString(this.Configuration, "DefaultConnectionSQL");

            services.AddDbContext <EscuelaContext>(
                options => options.UseSqlServer(connString)
                );

            //Inyectamos la conexión a la base de datos PostgreSQL

            /*string connString = ConfigurationExtensions.GetConnectionString(this.Configuration, "DefaultConnectionPostgreSQL");
             * services.AddDbContext<EscuelaContext>(
             *  options => options.UseNpgsql(connString)
             * );*/
        }
예제 #29
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            var connection = ConfigurationExtensions.GetConnectionString(this.Configuration, "DefaultConnection");

            services.AddDbContext <FinancialContext>(options => options.UseSqlServer(connection));
        }
예제 #30
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            string connString = ConfigurationExtensions.GetConnectionString(this.Configuration, "DefaultConnectionString");

            services.AddDbContext <db_concursoContext>(options => options.UseSqlServer(connString));
        }