当我将方法签名更改为任务实体框架时,会在SaveChanges处挂起。为什么会发生这种情况?
此代码失败
public async Task<bool> SaveAsync(agency agency)
{
using (var ctx = new AvnEntities())
{
try
{
ctx.agencies.Add(agency);
await ctx.SaveChangesAsync();
return true;
}
catch (System.Exception)
{
return false;
}
}
}
此代码有效
public async Task SaveAsync(agency agency)
{
using (var ctx = new AvnEntities())
{
try
{
ctx.agencies.Add(agency);
await ctx.SaveChangesAsync();
}
catch (System.Exception)
{
throw;
}
}
}