简体   繁体   中英

WCF Entity Framework 6 SQL Provider not found

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) 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM