The name 'EntityState' does not exist in the current context

asp.net-mvc, entity-framework, runtime-error

Solution

I fixed this issue as below

Namespace

using System.Data;
using System.Data.Entity;

I was working earlier in ASP.Net MVC C# application working fine for me. I fixed this issue as below

using System.Data;

I was working earlier in ASP.Net MVC C# application working fine for me

_context.Entry(_Teach).State = System.Data.EntityState.Modified;

Now, same method using in simple c#, WCF but it giving me issue then I did this in a way as below:

_context.Entry(_Teach).State = EntityState.Modified;

Problem

In Entity Framework, this sometimes occurs when the `System.data.entity` assembly is not added into the Project. But, why I didn't have this error before in other MVC project. it occurs sometimes but frequently and I have to add it manually in Add References. What can I do?

Original source

Related problems