Refactor DbContext configuration for flexibility
Updated `ConfigureDbContext` to accept `IServiceProvider`, enabling dependency injection during database context setup. Modified `DependencyInjection.cs` to align with this change by updating `DbContextOptionsAction` and its related method signature. Removed unused `System.IO` and `System.Text.Json` namespaces from `RecActionController.cs` to improve code cleanliness.
This commit is contained in:
@@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using ReC.API.Models;
|
||||
using ReC.Application.RecActions.Commands;
|
||||
using ReC.Application.RecActions.Queries;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ReC.API.Controllers;
|
||||
|
||||
@@ -16,7 +16,7 @@ builder.Services.AddRecServices(options =>
|
||||
|
||||
builder.Services.AddRecInfrastructure(options =>
|
||||
{
|
||||
options.ConfigureDbContext((dbContextOpt) =>
|
||||
options.ConfigureDbContext((provider, dbContextOpt) =>
|
||||
{
|
||||
var connectionString = builder.Configuration.GetConnectionString("Default")
|
||||
?? throw new InvalidOperationException("Connection string is not found.");
|
||||
|
||||
Reference in New Issue
Block a user