user1689571
user1689571

Reputation: 495

EF 4.1 Using System.Data.Entity and Still can use a Lambda Expression in my Include

I am using EF 4, and in other projects on my same machine I have not had this problem. I have:

using System.Data.Entity;

and

ctx.AdminUsers.Include(a => a.foo)...

but I get

Cannot convert lambda expression to type 'string' because it is not a delegate type

anyway.

Any thoughts on what I may have forgotten?

Upvotes: 0

Views: 139

Answers (1)

pilot
pilot

Reputation: 36

Sounds like your Entity Model is not configured to use DbContext.

You'll need to add the ADO.NET DBContext Generator as a code generation item to your Entity Model.

To switch to DBContext right click in the model UI and choose Add Code Generation Item, choose ADO.NET DbContext Generator and add it to the project. This will remove the classes within the model.designer.cs file and add new DbContext objects. You should now be able to work with these objects.

If your Entity Model is not in the same project as the application you may need to add a reference to the EntityFramework library in order for it to build after this change.

Upvotes: 2

Related Questions