Do I need to remove System.Data and System.Data.Common while upgrading EF5 to EF6

489 Views Asked by At

I'm following Microsoft Guide and it mentions that

  • Ensure that assembly references to System.Data.Entity.dll are removed

  • The general rule for namespace changes is that any type in System.Data.* is moved to System.Data.Entity.Core.*.

But my projects are using ADO.NET Objects such as:

  • 'DbException'
  • 'DataException'
  • 'DbCommand'
  • 'IDbDataParameter'
  • 'DbType'
  • 'IDbCommand'

How can I replace them? I'm looking these namespaces

System.Data.Entity.Core.EntityClient

Microsoft.Data.SqlClient

But couldn't find any replacement.

Is it still okay to use System.Data and System.Data.Common namespaces? If not, how can I replace them?

1

There are 1 best solutions below

0
pfx On

Below fragment from that Upgrading to Entity Framework 6 article, is to be read as that the mentioned namespace changes are to be applied on types that are in the System.Data.* namespace and originate from the System.Data.Entity.dll assembly.

Types like ObjectContext that were previously in System.Data.Entity.dll have been moved to new namespaces. This means you may need to update your using or Import directives to build against EF6.

The general rule for namespace changes is that any type in System.Data.* is moved to System.Data.Entity.Core.*.

The System.Data.Common namespace of e.g. the DbException type matches that namespace, but DbException is in the System.Data.Common.dll assembly, not in System.Data.Entity.dll.

For that reason DbException is still fine to be used, as are the other types you mentioned.


Entity Framework 6 itself makes use of types from the System.Data.Common namespace, see GitHub

That article also has below note about the System.Data namespace.

Some types in the System.Data namespace are in System.Data.dll which is not an EF assembly. These types have not moved and so their namespaces remain unchanged.