23 lines
877 B
C#
23 lines
877 B
C#
using IRaCIS.Core.Infra.EFCore;
|
||
using Microsoft.EntityFrameworkCore;
|
||
using Microsoft.Extensions.Configuration;
|
||
using Microsoft.Extensions.DependencyInjection;
|
||
|
||
namespace IRaCIS.Core.API
|
||
{
|
||
public class EFConfigure
|
||
{
|
||
public static void ConfigureEF(IServiceCollection services, IConfiguration configuration)
|
||
{
|
||
services.AddScoped<DbContext, IRaCISDBContext>();
|
||
|
||
//这个注入没有成功--注入是没问题的,构造函数也只是支持参数就好,错在注入的地方不能写DbContext
|
||
services.AddDbContext<IRaCISDBContext>(options =>
|
||
{
|
||
options.UseSqlServer(configuration.GetSection("ConnectionStrings:RemoteNew").Value,contextOptionsBuilder=> contextOptionsBuilder.EnableRetryOnFailure());
|
||
options.EnableSensitiveDataLogging();
|
||
});
|
||
}
|
||
}
|
||
}
|