Upgrade EntiryFramework 5.0.0 to 6.2.0 changes

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)
{
items.Attach(item);
entry.State = System.Data.EntityState.Modified;
}

to


if (entry.State == System.Data.Entity.EntityState.Detached)
{
items.Attach(item);
entry.State = System.Data.Entity.EntityState.Modified;
} 

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.