Changed parts of how data project stucture

This commit is contained in:
Giovani
2019-04-22 22:46:39 +00:00
parent 4e4fa572b7
commit 4074d101b2
13 changed files with 23 additions and 99 deletions

View File

@@ -32,10 +32,9 @@ namespace BrightGlimmer.Api
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddMediatR();
services.AddMediatR(typeof(Cqrs.Cqrs).Assembly); // Registers handlers in Cqrs project
services.AddScoped<SqliteStudentRepository, SqliteStudentRepository>(); /* REMOVE LATER */
services.AddScoped<MongoStudentRepository, MongoStudentRepository>(); /* REMOVE LATER */
services.AddDbContext<SqliteDatabaseContext>(options => options.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));
services.AddTransient<SqliteDatabaseContext>();
services.AddScoped<StudentRepository, StudentRepository>(); /* REMOVE LATER */
services.AddDbContext<SqliteContext>(options => options.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));
services.AddTransient<SqliteContext>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -56,7 +55,7 @@ namespace BrightGlimmer.Api
// Makes sure that the database is in fact created
using (var serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
{
var context = serviceScope.ServiceProvider.GetRequiredService<SqliteDatabaseContext>();
var context = serviceScope.ServiceProvider.GetRequiredService<SqliteContext>();
context.Database.EnsureCreated();
}
}