Reputation:
I'm getting the error
'EntityState' is an ambiguous reference between 'System.Data.EntityState' and 'System.Data.Entity.EntityState'
I'm getting this error on my 4 controllers using mvc5 entity framework.
The line in question is db.Entry(director).State = EntityState.Modified;
Same on each controller just different models.
Upvotes: 6
Views: 8936
Reputation: 61
no need to provide the fully-qualified. if there is two using on top of the page:
using System.Data; using System.Data.Entity;
just should delete (using System.Data;)
Note: delete another using like (using EntityState = System.Data.EntityState;)
Upvotes: 0
Reputation: 2089
You should use System.Data.Entity.EntityState
instead of System.Data.EntityState
.
Upvotes: 0
Reputation: 2944
There is two namespace added in your controller named System.Data
and System.Data.Entity
and both has EntityState
property. Compiler is confusing here and gives you the ambiguous reference
error. You need to specify the property with the namespace like
db.Entry(director).State = System.Data.Entity.EntityState.Modified;
Upvotes: 0
Reputation: 9881
Simply provide the fully-qualified EntityState depending on whichone you want:
db.Entry(director).State = System.Data.EntityState.Modified;
or
db.Entry(director).State = System.Data.Entity.EntityState.Modified;
Upvotes: 2