user7200423
user7200423

Reputation:

'EntityState' is an ambiguous reference between 'System.Data.EntityState' and 'System.Data.Entity.EntityState'

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

Answers (4)

mohsen Abdi
mohsen Abdi

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

Imran
Imran

Reputation: 2089

You should use System.Data.Entity.EntityState instead of System.Data.EntityState.

Upvotes: 0

Mahedi Sabuj
Mahedi Sabuj

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

Andy T
Andy T

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

Related Questions