Error: The type "System. Data. EntityState" cannot be implicitly converted to "System. Data. Entity. EntityState ",
Error: The type "System. Data. EntityState" cannot be implicitly converted to "System. Data. Entity. EntityState"
Cause 1:
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using System. Threading. Tasks;
Using System. Data. Entity;
Referenced?System. Data. Entity: db. Entry <UserInfo> (entity). State = EntityState. Deleted;
Otherwise, addDb. Entry <UserInfo> (entity). State = System. Data. EntityState. Deleted;
Add namespace
Cause 2:
The error statement stays at: DataContext. Entry (entity). State = EntityState. Modified;
There are no syntax errors. DataContext is automatically generated by adding edmx to the Model layer, and the latest Entity Framework is installed on the data layer where error statements are located. We know that when an Entity is created in edmx to import a database, VS will automatically install Entity Framework for us. Is the EF version different from the data layer?
Solution
Uninstall EF: Uninstall-Package EntityFramework-Force first
Install EF5.0: Install-Package EntityFramework-Version 5.0.0