【发布时间】:2021-02-22 00:16:55
【问题描述】:
我正在使用 EF Core 开发 .NET Core 3.1 Web API,并且此 API 已部署到 AWS Lambda。下面代码中面临的问题是,它一直执行到控制台日志。然后在 api 返回以下带有状态码的消息后
504 网关超时:
"message": "端点请求超时"
CoreContext 扩展DbContext:
public async Task<IList<ChannelsEnvelope>> GetChannels()
{
using (var scope = _services.CreateScope())
{
Console.WriteLine("inside scope123"); // works till here.
var _coreContext = scope.ServiceProvider.GetRequiredService<CoreContext>();
var query = from a in _coreContext.DistributionChannels
where a.Active == true
orderby a.Channel ascending
select new ChannelsEnvelope
{
ID = a.Id,
Channel = a.Channel,
Description = a.Description
};
return await query.AsNoTracking().ToListAsync();
}
}
【问题讨论】:
标签: c# amazon-web-services asp.net-core aws-lambda entity-framework-core