I am having a tough time to understand why this code is failing
I have a test method
IUnitOfWork unitofwork = EFUnitOfWork.CreateInstance();
IRepository<InformationRequest> informationRequestRepository = unitofwork.CreateRepository<InformationRequest>();
IEnumerable<InformationRequest> requests = informationRequestRepository.ToList();
unitofwork.Dispose();
EFUnityOfWork.CreateInstance calls the EFUnitOfwork Constructor
public EFUnitOfWork()
{
_currentContext = new MyDataContext();
}
Here is the code for CreateRepository
public IRepository<T> CreateRepository<T>()
{
return new Repository<T>(_currentContext);
}
The test above doesnt work on a load test. When i try to run it it says System.Data.EntityException: The underlying provider failed on Open. ---> System.InvalidOperationException: The connection was not closed. The connection's current state is connecting.
I am disposing the context and creating a new one everytime. I dont understand where i am going wrong