Entity Frame Work always return null

app-config asp.net-mvc c# entity-framework entity-framework-6


I'm created windows service where I have problem in calling query using entity frame-work inside this service, its always return null.

I tried to reinstall entity-framework package from NuGet but nothing happend.

this is my app.config file part:

<add name="GPSContext" connectionString="data source=server_name;initial catalog=dbName;user id=username;password=****;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" /> 

and (

The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded.

) run time error returned when I configured my entity-framework:


    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />


    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
        <parameter value="mssqllocaldb" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
7/16/2018 11:55:05 AM

Popular Answer

You can do a couple of things...

Make sure you have both EntityFramework and EntityFramework.SqlServer added to the references of the calling assembly.

If this will not fix your problem you can delete the BIN folder and try again.

If this still isn't working add the following code somewhere in your calling assembly

internal static class MissingDllHack
   // Must reference a type in EntityFramework.SqlServer.dll so that this dll will be
   // included in the output folder of referencing projects without requiring a direct 
   // dependency on Entity Framework. See http://stackoverflow.com/a/22315164/1141360.
   private static SqlProviderServices instance = SqlProviderServices.Instance;

the compiler sometimes removes the entityFramework.SqlServer.dll if its not referenced! You do not need to do anything with this code!

7/16/2018 12:08:31 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow