2

We have legacy connection strings in use by different sql clients from years past. The connection string has legacy syntax: "Provider=SQLOLEDB".

Provider=SQLOLEDB;Data Source=<servername>;Initial Catalog=<dbname>;Integrated Security=SSPI

EF6 uses different SQL client and providers obviously.

So my question is, does there exist a way to configure EF6 to use a provider or connection provider factory that will know how to deal with the provider keyword in the connection string? Currently I'm getting the error message

Keyword not supported: 'provider'.

I was hoping there might be a way to avoid changing the connection string that doesn't involve a run-time tweak to remove the keyword from the original connection string.

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
Colin
  • 331
  • 3
  • 19
  • You could try to parse those connections strings and build a new one, with the proper syntax, from the parts. This is why it's always better to save the server, db name, user, passwords individually instead of a whole connection string. – Alejandro Oct 23 '17 at 16:06

1 Answers1

0

The problem is that Entity Framework is a .NET thing. And in ADO.net you are not allowed to use the SQLOLEDB provider.

Even though you are actually using the OleDbConnection class, and normally OLEDB lets you specify the OLEDB Provider, you're just not allowed to here.

The ADO.net OleDbConnection class detects if you try to use the SQLOLEDB provider, and simply throws an error.

I know that's not (yet) what you're seeing here. What you're seeing here is explained here:

The approach you are using to build the EF connection string is correct.

BUT...

The Entity Framework only works with Providers (i.e. SqlClient) that support something called provider services.

The OleDB provider doesn't support 'Provider Services' so you can't use EF with the OleDb (unless you can find a third party OleDb provider with support for EF).

Hope this helps

Alex

(Entity Framework Team, Microsoft)

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219