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

asp.net-mvc entity-framework runtime-error

Question

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?

1
11
7/29/2013 12:45:19 PM

Accepted Answer

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;
5
2/22/2016 7:56:49 AM

Popular Answer

Try changing

e.g.

System.Data.EntityState.Modified;

to

System.Data.Entity.EntityState.Modified;

(Not sure what's going on. Did Microsoft change the package?)



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow