I\'m evaluating unit tests using EF6 in combination with
http://www.codeproje
We were seeing the same errors when running all UnitTests on our build server or when running all UnitTests locally.
System.InvalidOperationException : The Entity Framework was already using a DbConfiguration instance before an attempt was made to add an 'Loaded' event handler. 'Loaded' event handlers can only be added as part of application start up before the Entity Framework is used.
Once we moved the Effort Provider registration code from the [TestInitialize] method to the AssemblyInitialize method, everything started working. Based on the message in the reported error, it appears that the registration cannot happen more than once.
[AssemblyInitialize()]
public static void AssemblyInit(TestContext context)
{
Effort.Provider.EffortProviderConfiguration.RegisterProvider();
}