Entity Framework 7 with ASP.NET 4.6

.net asp.net-web-api c# entity-framework entity-framework-core

Question

The question is quite simple: Is it possible to use Entity Framework 7 (beta4) with ASP.NET 4.6 (Web Api in my case)?

For the moment I cannot make it work, the following exception is always raised:

An exception of type System.InvalidCastException occured in Microsoft.Framework.DependencyInjection.Interfaces.dll but was not handled in user code.

Additional information: Unable to cast object of type Microsoft.Framework.Logging.LoggerFactory to type Microsoft.Framework.Logging.ILoggerFactory.

This error is quite strange since I do not use any logging functionnality of EF 7. It has maybe something with registration to do? I read that with ASP.NET 5, you have to register EF like this: services.AddEntityFramework(), which I'm currently not doing since I'm using Version 4.6...

Accepted Answer

This is a possibly likely a bug in EF 7. The issue is being tracked here aspnet/EntityFramework#2606.

Update

As a workaround, try using the nightly builds and make sure that you have the latest versions of both EF 7, Microsoft.Framework.DependencyInjection, and Microsoft.Framework.Logging.




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why