When I start my page everything loads fine I try to reload for the second time I get the following error I run the urls from angular
A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context. Any instance members are not guaranteed to be thread safe.
This is the method
private readonly PuntovService puntovService = new PuntovService(new PuntovRepository(CentralContext.Create()));
private readonly IMapper mapper;
public PuntovController()
{
this.mapper = WebApiApplication.MapperConfiguration.CreateMapper();
}
[HttpGet]
[Route("Puntos")]
[ResponseType(typeof(IEnumerable<PuntovDTO>))]
public async Task<IHttpActionResult> GetAll()
{
var pv = await puntovService.GetAll();
var puntovDTO = pv.Select(x => mapper.Map<PuntovDTO>(x));
var tipoComitePersona = from com in puntovDTO
select new {com.PuntoV};
return Ok(tipoComitePersona);
}
in this class call the context that would be the database
using APICentralBL.Models;
using System.Data.Entity;
namespace APICentralBL.Data
{
public class CentralContext : DbContext
{
private static CentralContext centralContext = null;
public CentralContext() : base("Context")
{
}
public DbSet<SDN> SDN { get; set;}
public DbSet<CALIF> CALIF { get; set; }
public DbSet<UVT> UVT { get; set; }
public DbSet<PUNTOV> PUNTOV { get; set; }
public DbSet<TRANS> TRANS { get; set; }
public static CentralContext Create()
{
if (centralContext == null)
centralContext = new CentralContext();
return centralContext;
}
}
}
It not only happens with this method, it happens when I try to call more than one
ex.StackTrace
en System.Data.Entity.Internal.ThrowingMonitor.EnsureNotEntered()
en System.Data.Entity.Core.Objects.ObjectQuery`1.System.Data.Entity.Infrastructure.IDbAsyncEnumerable<T>.GetAsyncEnumerator()
en System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.ForEachAsync[T](IDbAsyncEnumerable`1 source, Action`1 action, CancellationToken cancellationToken)
en System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.ToListAsync[T](IDbAsyncEnumerable`1 source, CancellationToken cancellationToken)
en System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.ToListAsync[T](IDbAsyncEnumerable`1 source)
en APICentralBL.Repositories.Implements.GenericRepository`1.<GetAll>d__3.MoveNext() en D:\ANTIOQUENA DEVELOPERS REPOSITORY\ANTIOQUENA DEVELOPERS\DEVELOPMENTS\API'S PROJECT\APICentral-Deploy\APICentralBL\Repositories\Implements\GenericRepository.cs: línea 33
en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
en System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
en APICentralBL.Services.Implements.GenericService`1.<GetAll>d__3.MoveNext() en D:\ANTIOQUENA DEVELOPERS REPOSITORY\ANTIOQUENA DEVELOPERS\DEVELOPMENTS\API'S PROJECT\APICentral-Deploy\APICentralBL\Services\Implements\GenericService.cs: línea 25
en System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
en System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
en System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
en APICentral.Controllers.PuntovController.<GetAll>d__4.MoveNext() en D:\ANTIOQUENA DEVELOPERS REPOSITORY\ANTIOQUENA DEVELOPERS\DEVELOPMENTS\API'S PROJECT\APICentral-Deploy\APICentral\Controllers\PuntovController.cs: línea 65**