1
votes

i write a client server application. If the server request data from EF6 there is no problem and no exception. If the client asks over WFC data from the EF6 there is a provider not found exception. My database is a MS SQL Server 2017. CLient and Server have the same debug folder.

Exception over WFC:

"No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlClient'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information."

Server App.config

<?xml version="1.0" encoding="utf-8"?>

Integrated Security=True;Database=PeddTax;MultipleActiveResultSets=True"/>

<system.web>
    <compilation debug="true" />
</system.web>

<system.serviceModel>
    <services>
        <service name="PeddTaxServer.Communication.UserService">
            <endpoint address="http://localhost:6060/wcf/UserService" binding="basicHttpBinding"
                bindingConfiguration="" name="UserServiceEndpoint" contract="PeddTax.Communication.Interfaces.IUserService" />
        </service>
    </services>
</system.serviceModel>

Client App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
</startup>

<system.serviceModel>
    <client>
    <endpoint address="http://localhost:6060/wcf/UserService" 
      binding="basicHttpBinding" bindingConfiguration="" 
      contract="PeddTax.Communication.Interfaces.IUserService" 
      name="UserServiceEndpoint" kind="" endpointConfiguration="" />
    </client>
</system.serviceModel>

<system.web>
    <compilation debug="true" />
</system.web>
</configuration>

IUserInterface for WFC

[ServiceContract]
public interface IUserService
{
    [OperationContract]
    void AddUser(User user);

    [OperationContract]
    void UpdateUser(User user);

    [OperationContract]
    User GetUser(Guid id);

    [OperationContract]
    List<User> GetUsers();

    [OperationContract]
    void DeleteUser(User user);
}

UserService for WFC

    public class UserService : IUserService, IService
{
    UserRepository userRep = new UserRepository();

    public void AddUser(User user)
    {
        userRep.Add(user);
        userRep.Save();
    }

    public void DeleteUser(User user)
    {
        userRep.Delete(user);
        userRep.Save();
    }

    public User GetUser(Guid id)
    {
        return userRep.GetSingle(id);
    }

    public List<User> GetUsers()
    {
        return userRep.GetAll().ToList();
    }

    public void UpdateUser(User user)
    {
        userRep.Edit(user);
        userRep.Save();
    }
}

In the userRepository there is this method

public IQueryable<T> GetAll()
{
    IQueryable<T> query = entities.Set<T>();
    return query;
}
1
What else do you need besides the error message?astef
I have no idea why there is an error. If the server request the data from GetAll() there is no exception but if the client over WFC request it then there is a exception. Why?Lyror
Because GetAll() doesn't access the database. Query materialized only after ToList() callastef
I changed it but now it runs in a timeout by calling ToList() in GetAll()Lyror
Timeout indicates the problem with your connection string or remote server accessibility. At least now you know that database is called in the right place.astef

1 Answers

0
votes

1) Turn on all exceptions in Visual Studio if you want to see the place where it is thrown.

2) Re-install EF on a correct project as suggested here