c# - DbSet doesn't contain definition for FirstOrDefault? -


i migrated existing project .net 4.5 , changed out project using data access (switching entity framework).

for reason time try access functions dbset (where, first, firstordefault, etc) throws error:

error 53 'system.data.entity.dbset1<myproject.data.customer>' not contain definition 'firstordefault' , no extension method 'firstordefault' accepting first argument of type 'system.data.entity.dbset1' found (are missing using directive or assembly reference?

this uses .net 4.5 , read these functions no longer in system.linq stored in system.core. have added reference system.core project still getting error. there using statement system.linq, not system.core.

can see why getting error? suggestions on how fix?

update:

this line throws error:

vimodel db = new vimodel(); customer = db.customers.firstordefault(c => c.customerid == customerid && c.isprimary); 

and dbcontext:

public partial class vimodel : dbcontext {      ........      public virtual dbset<customer> customers { get; set; }      ........ } 

the assembly queryable (the thing adds firstordefault extension method using) in system.core, it's namespace system.linq, can see on msdn page it

namespace: system.linq
assembly: system.core (in system.core.dll)

you need have in project refrence system.core , in file trying use using system.linq;

if have both of these things double check project or project refrencing did not create it's own system.data.entity.dbset<t> class not implement iqueryable<t> or ienumerable<t>.


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -