//public IApplicationBuilder public void ConfigureServices(IServiceCollection services) { var connectString = Configuration.GetConnectionString("cloudmedicsDbConnection"); services.AddDbContext <CloudMedicDbContext>(); services.AddEntityFrameworkMySql(); services.AddAutoMapper(); services.AddIdentity <ApplicationUser, IdentityRole>() .AddEntityFrameworkStores <CloudMedicDbContext>() .AddDefaultTokenProviders(); services.Configure <IdentityOptions>(options => options.ConfigureIdentiyOptions()); services.AddAuthentication(option => { option.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; option.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(options => options.ConfigureJWTBearerOptions(Configuration)); services.AddCors(options => options.ConfigureCorsPolicy()); services.Configure <IISOptions>(config => config.ForwardClientCertificate = false); //register framework services services.AddMvc(); //register application services services.AddTransient <IUserRepository, UserRepository>(); services.AddTransient <IPatientUserRepository, PatientUserRepository>(); services.AddTransient <IAccountService, AccountService>(); services.AddTransient <IPatientUserService, PatientUserService>(); services.AddTransient <AppDbInitializer>(); ConfigSettingsHelper.Create(Configuration); }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { IConfiguration configuration = ConfigSettingsHelper.GetConfiguration(); var connectionString = configuration.GetConnectionString("cloudmedicsDbConnection"); optionsBuilder.UseMySql(connectionString); base.OnConfiguring(optionsBuilder); }