0

I currently have a solutuion with two projects.

a blank project called domain which has the ef installed etc.

Now I have a c# form project that makes use of the domain project.

When I make calls to the domain project from teh forms I get the following error:

Additional information: 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.

Do I need to install EF on the form project?

Here is a class in my Domain Project:

  /// <summary>
/// Provides Operations to the databse regarding all Service History Requests
/// </summary>
public class EFServiceStatusHistoryRepository
{

    public void SubmitEntry(int ServiceId, string Status, string Messages, DateTime LastUpdated)
    {
        try
        {
            ServiceStatusHistory tmp = new ServiceStatusHistory();

            using (var db = new EFDbContext())
            {
                tmp.Service = db.Services.Find(ServiceId);
                tmp.Status = (ServiceStatus)Enum.Parse(typeof(ServiceStatus), Status);
                tmp.SetMessages(Messages);
                tmp.time = DateTime.Now;
                tmp.LastUpdateTime = LastUpdated;

                db.ServiceStatusHistory.Add(tmp);
                db.SaveChanges();
            }
        }
        catch
        {

        }
    }
}

And I then call it in the forms project:

EFServiceStatusHistoryRepository service = new EFServiceStatusHistoryRepository();
service.SubmitEntry(bla,bla,bla);

it was my understanding that only the DOMAIN project needed EF installed. as the function I am calling does all the EF work in that project and then returns a List to the forms project?

Microsoft DN
  • 9,706
  • 10
  • 51
  • 71
Zapnologica
  • 22,170
  • 44
  • 158
  • 253

2 Answers2

0

Try running following command on Package Manager Console (Tools -> Library Package Manager-> Package Manager Console)

PM> Install-Package EntityFramework

Or try adding following config to your web.config file

<providers>
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
  <provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>
Microsoft DN
  • 9,706
  • 10
  • 51
  • 71
0

I think you do from EF6 onwards; I had a very similar problem just a few days ago, when I updated EF in some of my projects using Nuget.

Other answers to that same question indicate the same conclusion.

Community
  • 1
  • 1
Kjartan
  • 18,591
  • 15
  • 71
  • 96