엔티티 프레임 워크 코어 및 mysql 커넥터가있는 내 dotnet 코어 프로젝트에 성능 문제가 있습니다. 1 요청 모두가 몇 요청 후엔티티 프레임 워크 연결 및 쿼리 증가
작업처럼 보인다 후
public async Task<Vehicle[]> GetAllVehicles()
{
_logger.LogInformation("Getting All vehicles");
using (var dbContext = MhdContextFactory.Create(_dbConfig.ConnectionString))
{
var vehicles = await dbContext.Vehicles.AsNoTracking()
.FromSql("SELECT * FROM Vehicles AS v group by v.VehicleId order by LastUpdate")
.ToArrayAsync();
return vehicles;
}
}
:이 메소드를 호출 내 컨트롤러에 http://insidemysql.com/howto-starting-with-mysql-ef-core-provider-and-connectornet-7-0-4/
public class MhdContext : DbContext
{
public MhdContext(DbContextOptions<MhdContext> options) : base(options) { }
public DbSet<Vehicle> Vehicles { get; set; }
}
public static class MhdContextFactory
{
public static MhdContext Create(string connectionString)
{
var optionsBuilder = new DbContextOptionsBuilder<MhdContext>();
optionsBuilder.UseMySQL(connectionString);
//Ensure database creation
var context = new MhdContext(optionsBuilder.Options);
context.Database.EnsureCreated();
var serviceProvider = context.GetInfrastructure<IServiceProvider>();
var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
loggerFactory.AddProvider(new MyLoggerProvider());
return context;
}
}
:
나는 다음 튜토리얼에 의해 dbcontext 생성 중복 SQL 명령이며 증가 중 일곱 번째 요청 로그 : https://www.dropbox.com/s/2ezyowyubq1orsn/7thRequest.txt?dl=0
내가 잘못하고있는 것을 도와 줄 수 있습니까?