Avrohom Yisroel
Avrohom Yisroel

Reputation: 9472

"Cannot convert lambda expression to type 'string' because it is not a delegate type" in .NET 4.5

I am trying out an existing .NET 4.0 solution in VS2012 on a test machine (that only has VS2012 and SQL Server 2008 installed), and am getting the above error when I try to use the lambda syntax with the Include extension method.

The existing version of the solution has a reference to EntityFramework.dll, which is the one I had to add to use the Include method, but the upgraded version I'm looking at in VS2012 does not have such a reference, nor can I find a DLL of that name in the location it was on the other machine. The using statement for System.Data.Entity is greyed out, as ReSharper thinks it isn't needed. Don't know why.

Sample code: This is what is in the existing solution...

using (var context = new RSSFeedsEntities()) {  
  WebSite someSite = context.WebSites.Include(w => w.Feeds).FirstOrDefault(w => w.WebSiteID == 1);  
}

Any idea how to solve this? Thanks

Upvotes: 1

Views: 714

Answers (1)

Avrohom Yisroel
Avrohom Yisroel

Reputation: 9472

Ah ha! Found the answer.

Microsoft, in their, ahem, wisdom, made the (in my opinion) blindingly stupid decision not to have Entity Framework install like other bits of the development rack, but instead made the recent versions only available as NuGet packages. Why on earth they did this is beyond me, as I now have to install EF separately for every solution, instead iof installing it cone and having it available immediately.

Anyway, I used the NuGet package manager to install EF 5.0, and the error went away.

Hope this helps someone.

Upvotes: 2

Related Questions