2011-09-25 65 views
0

從下面的代碼片段中,獲取錯誤「無法找到類型或名稱空間名稱」實體「」。 因此,我添加了參考「System.Data.Entity」,但它仍然不能正常工作...GDataDB示例中的實體錯誤

這是爲什麼?


錯誤1類型或命名空間名稱「實體」找不到(是否缺少using指令或程序集引用?)...


  using System; 
      using System.Linq; 
      using GDataDB; 
      using GDataDB.Linq; 
      using System.Data.Entity; 
      .... 
      Console.WriteLine("Connecting"); 
      var client = new DatabaseClient("[email protected]", "password"); 
      const string dbName = "testing"; 
      Console.WriteLine("Opening or creating database"); 
      var db = client.GetDatabase(dbName) ?? client.CreateDatabase(dbName); 
      const string tableName = "testtable"; 
      Console.WriteLine("Opening or creating table"); 
      var t = db.GetTable<Entity>(tableName) ?? db.CreateTable<Entity>(tableName); 
      Console.WriteLine("Feed url for this table is '{0}'", t.GetFeedUrl()); 
      var all = t.FindAll(); 
      Console.WriteLine("{0} elements", all.Count); 
      .... 
+1

看起來您正在使用LINQ-to-SQL非實體框架。你必須爲'db.GetTable'提供一個有效的類 – Eranga

回答

1

沒有using System.Data.Entity;GDataDB sample appnever has been,所以無論你或一些自動化工具添加它。

所以簡單地刪除它。

如果你錯過了Entity型,確保您得到whole sample project並不僅僅是Program.cs中

GDataDB有EF或LINQ到SQL完全沒有關係。