Azure / azure-functions-dotnet-worker-preview

MIT License
65 stars 19 forks source link

Error when using EF Core 5: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions' #21

Closed djjlewis closed 3 years ago

djjlewis commented 3 years ago

I'm trying to upgrade an existing function using the code example in this repo as the basis, but I am hitting the following error while running the function:

Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Value cannot be null. (Parameter 'provider')

I had a number of implicit references to various .net 5 packages via other project references, but can now repro if I just add a reference to Microsoft.EntityFrameworkCore.SqlServer version 5.0.1

I tried to explicitly downgrade to the Configuration.Abstractions package 3.1.10 based on reading some similar issues which were solved with a downgrade, however when I do that EF 5 complains because it requires version 5 of this package.

This is a bit of showstopper for us as we need to use EF within the functions. Do you know if this should work or if there are any known workarounds?

n1ghtl10n commented 3 years ago

I have the same issue. We converted to .net 5, but depending on if there is a workaround in the upcomming weeks we will need to downgrade.

iloabn commented 3 years ago

Same issue appears with the package Microsoft.Identity.Web. I've verified using version 0.1.0-preview, 1.0.0 and the latest 1.5.1. Simply adding that package to the .csproj file in the example project (this repro) produces the same issue as reported above.

I also tested adding the same package to a "File -> New" netcore3.1 Azure Function, doing so did not create the same issue.

jeffhollan commented 3 years ago

Have a repro of original issue here: https://github.com/jeffhollan/functions-net5-entityframework

iloabn commented 3 years ago

After having upgraded to v1.0.0-preview3 I'm no longer seeing this issue. I also tested with the package Microsoft.EntityFrameworkCore.SqlServer that @djjlewis mentioned in the original post and that seems to be working for me at the moment. Are the others in this thread still having the same issue with the latest package version, or is it working now for you as well?

Edit: I've also verified this with v1.0.0-preview4.

fabiocav commented 3 years ago

Closing this as resolved, but please let us know if you continue to run into issues.