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:
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
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!