Skip to content

Commit 044d940

Browse files
Just a little refactoring
1 parent f8da78a commit 044d940

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Commander/Startup.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ public Startup(IConfiguration configuration)
3030
// This method gets called by the runtime. Use this method to add services to the container.
3131
public void ConfigureServices(IServiceCollection services)
3232
{
33-
services.AddDbContext<MyDbContext>(opt => opt.UseSqlServer
34-
(Configuration.GetConnectionString("CommanderConnection")));
35-
3633
services.AddControllers();
3734
services.AddSwaggerGen(c =>
3835
{
@@ -41,8 +38,13 @@ public void ConfigureServices(IServiceCollection services)
4138

4239
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
4340

41+
// From -> Into (dependency injection)
42+
4443
//services.AddScoped<ICommanderRepository, CommanderRepository>();
4544
services.AddScoped<ICommanderRepository, SqlCommanderRepository>();
45+
46+
services.AddDbContext<MyDbContext>(opt => opt.UseSqlServer
47+
(Configuration.GetConnectionString("CommanderConnection")));
4648
}
4749

4850
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

0 commit comments

Comments
 (0)