Unable to load DLL 'sni.dll' - Entity Framework Core

Adding nuget package System.Data.SqlClient v4.4.0 solved the same problem for me. The problem is not specific to Entity Framework. It is caused by older version of SqlClient dependency on APIs not available in dotnet Core 2.


In some instances this issue can be caused by IIS not having sufficient permissions to access areas of your %USERPROFILE%.nuget

This can be solved in one of two simple ways:

Grant permission to the IIS appPool (like DefaultAppPool or FooAppPool) to access not only the .Nuget folder (this is usually done automatically).

Set the AppPool being used to run as 'LocalSystem' under Identity, this way the appPool will be treated as having higher permissions and should have access.

Here's a series of references for where other users have had this error, 'solved' several years ago:

https://github.com/Azure/app-service-announcements-discussions/issues/9
https://github.com/dotnet/cli/issues/5262
https://github.com/dotnet/corefx/issues/5252
https://github.com/dotnet/corefx/issues/30518

All of these reference the version of SQLClient (while this is relevant, it's a legacy issue), but one smart guy @azisoft (this link) realised this and has helped many thanks to it.