You are here

Upgrade EntiryFramework 5.0.0 to 6.2.0 changes

Submitted by Asif Nowaj, Last Modified on 2019-11-08

If you are migrating your application where Entity Framework 5.0.0 (EF 5) is used, to latest .NET framework 4.8 from 4.6 range, then after upgrading your .NET framework, you will be advised to upgrade Entity Framework as well.

Once I upgraded Entity Framework to 6.2.0 (EF 6), we have encountered with some compilation issue. like below:

Operator '==' cannot be applied to operands of type 'EntityState' and 'EntityState'

Do not worry, this is not a huge change.

Wherever you have used "System.Data.EntityState" needs to be changed to "System.Data.Entity.EntityState".

With EF 6.0 the code snippet in DbContextRepository.cs goes from:

if (entry.State == System.Data.EntityState.Detached)
entry.State = System.Data.EntityState.Modified;


if (entry.State == System.Data.Entity.EntityState.Detached)
entry.State = System.Data.Entity.EntityState.Modified;

Discussion or Comment

If you have anything in mind to share, please bring it in the discussion forum here.