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

4

14

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.

Lougheed answered 4/2, 2011 at 13:25 Comment(0)
L
3

Old(from 7 Fabruary 2013): It is impossible to add Npgsql provider to be accesible in Visual Studio, because NpgSql for now does not support DDEX.

Update on 29 of December 2013: It seems that DDEX support was added.

Lougheed answered 7/2, 2011 at 15:29 Comment(2)
We are working on this support. We hope to get it added soon.Nymphet
Just a follow up: We added support for that in our 2.2 beta1. You can get more information about how to compile, configure and install it here: github.com/npgsql/Npgsql/wiki/… I hope it helpsNymphet
F
3

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.

Fredel answered 4/2, 2011 at 15:6 Comment(2)
I added to machine.config file Npgsql provider, but noting happened.Lougheed
You must choose the right machine.config to edit. In case of 64 bit system, edit the c:\Windows\Microsoft.NET\Framework64\v4.0.*\Config\machine.config, otherwise use the directory "Framework" instead of "Framework64" to locate the right config file.Hage
L
3

Old(from 7 Fabruary 2013): It is impossible to add Npgsql provider to be accesible in Visual Studio, because NpgSql for now does not support DDEX.

Update on 29 of December 2013: It seems that DDEX support was added.

Lougheed answered 7/2, 2011 at 15:29 Comment(2)
We are working on this support. We hope to get it added soon.Nymphet
Just a follow up: We added support for that in our 2.2 beta1. You can get more information about how to compile, configure and install it here: github.com/npgsql/Npgsql/wiki/… I hope it helpsNymphet
J
2

If you want to list up Npgsql in Datasource list in Visual Studio, this article may be a little helpful.

Anyway, since Visual Studio is delivered by Microsoft, obviously you need to work on the registry table.

Jaynejaynell answered 6/9, 2012 at 4:14 Comment(0)
K
0

From: http://fxjr.blogspot.com/2011/05/npgsql-design-time-support-preview.html

comes a very important step you have to make: Inside Npgsql.Designer2 folder, there is a file called NpgsqlProvider.gen.reg. You have to merge this file to your registry every time you start VS.Net to debug the project

Kania answered 5/9, 2011 at 6:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.