2

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...

4
  • What does your project.json look like?
    – bricelam
    Jul 13, 2015 at 16:46
  • Like I wrote, I use ASP.NET 4.6, thus no project.json...
    – nicolas
    Jul 13, 2015 at 16:52
  • What does your packages.config and <runtime> section of your Web.config look like?
    – bricelam
    Jul 13, 2015 at 22:33
  • I managed to make it work with the latest beta6-13679 nightly build. Thanks for your help.
    – nicolas
    Jul 14, 2015 at 7:02

1 Answer 1

2

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.

7
  • How to test Entity Framework 7 then? Is there a workaround? I tried to downgrade to beta 3, but obviously that's not possible...
    – nicolas
    Jul 13, 2015 at 16:51
  • Updated. Try using a newer build of EF and its dependencies. Jul 13, 2015 at 16:58
  • Ok, then I will try with the latest beta6-13679. I'm currently using the beta4 (the latest available version via the official nuget)
    – nicolas
    Jul 13, 2015 at 17:10
  • Welcome to the world of nightly builds. Expect many more bugs. Feel free to contribute at github.com/aspnet/EntityFramework/issues Jul 13, 2015 at 18:12
  • Humm it does not work, I updated my Nuget repository with the url you suggested, but when I try to install the beta6-13679, I see the following message in the VS Output Console: "Attempting to resolve dependencies for package (...)" and then it hangs up... Do you know when the next official beta (5) will be released?
    – nicolas
    Jul 13, 2015 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.