Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add custom DB provider to be accessible in Visual Studio?

I wanted to work with custom DB provider in Visual Studio. I need it to use Entity Framework.

For example, I downloaded NpgSQL, registered them in GAC:

gacutil  -i  c:\temp\npgsql.dll
gacutil  -i  c:\temp\mono.security.dll

and added to machine.config file:

<add name="Npgsql Data Provider"
invariant="Npgsql"  support="FF"
description=".Net Framework Data Provider for Postgresql Server"
type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.6.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />

But Npgsql did not appear in Datasource list in Visual Studio:

Data source in VS

How to add custom DB provider to this list?

UPD: If I use command string edmgen.exe I got error:

error 7001: Failed to find or load the registered .Net Framework Data Provider.

like image 784
Anton Avatar asked Feb 04 '11 13:02

Anton


Video Answer


1 Answers

You need to declare the DbFactoryProvider in a config file (Web.config, Machine.config, etc). Here's a sample one I pulled from a project using MySQL:

<system.data>
  <DbProviderFactories>
    <remove invariant="MySql.Data.MySqlClient"/>
    <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
  </DbProviderFactories>
</system.data>

I also prefer declaring these in the application-level config files and have my apps use the local copy of the assembly. This helps with portability since we can't guarantee that the 3rd party provider is available in GAC.

like image 93
The Moof Avatar answered Oct 03 '22 12:10

The Moof