Search code examples
c#sqllinqentity

Can't reference my Entity Model for Sql-to-Linq query


I've made an entity model in a folder called "Entity" that contains my only entitymodel.

project.Entity.ListModel.edmx

Within my main program.cs, I'm trying to call upon it to navigate some of the tables:

var query = ListModel.TableName.Where(x => x.name.. 

But it keeps saying ListModel does not exist in current context. I've even tried the full path like: project.Entity.ListModel.TableName.Where..... But no luck.

This seems like a simple fix, though I'm not well aquainted with Entity Frameworks or Linq for that matter.

Any guidence would be welcome. Thanks


Solution

  • I realised I had not initialised entity class properly. Did that and was able to get it sorted.

    Entity context = new Entity();