2014-02-19 23 views
0

我目前有兩個項目的solutuion。EF我是否需要將其安裝在引用項目的項目中,該項目已與EF

一個名爲領域的空白項目,該項目已安裝等EF

現在我有一個C#項目的形式,使得使用域項目。

當我做從格蘭形式出現以下錯誤域項目要求:

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.

我需要在表格項目安裝EF?

這裏是我的領域工程類:

/// <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 
     { 

     } 
    } 
} 

然後我把它在形式的項目:

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

這是我的理解只有域項目所需要安裝的EF。作爲我所調用的函數,所有EF都在該項目中工作,然後將List返回給表單項目?

回答

0

我認爲你從EF6起就是這麼做的;幾天前我有a very similar problem,當時我在使用Nuget的一些項目中更新了EF。

對同一問題的其他答案也表明了相同的結論。

0

嘗試運行下面的程序包管理器控制檯命令(工具 - >庫包管理器 - >軟件包管理器控制檯)

PM> Install-Package EntityFramework 

或者嘗試添加下面的配置到web.config文件

<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> 
+0

在Forms項目中? – Zapnologica