3

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?

Hakoo Desai
  • 341
  • 3
  • 4
  • 21
  • Entity Framework also uses ADO.NET objects. EF isn't a data access library, it's an ORM that works on top of ADO.NET. EF generates the SQL commands that get executed by ADO.NET. In any case, EF 5 is very old - it was released in 2012. Even EF 6 is 10 years old, released in 2013. When it was first released MS was still trying to make everyone use its products, hence everything, including the SQL Server client, was in the `System.Data` namespace. – Panagiotis Kanavos Feb 13 '23 at 14:28

1 Answers1

3

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.

pfx
  • 20,323
  • 43
  • 37
  • 57