Bonjour,
Je rencontre une difficulté pour générer un EDMX d'une base de données PostgreSQL via NpgSql et EdmGen2.
1) J'ai rajouter dans le GAC (copier/coller dans C:\WINNT\assembly):
- Npgsql.dll(2.0.11.91)
- Mono.Security.dll (2.0.0.0)
2) J'ai rajouter dans la section <system.data><DbProviderFactories>
- <add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.11.91, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
Ceci pour le fichier:
- C:\WINNT\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config
- C:\WINNT\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
3) Je télécharge Edmgen2
4) Je lance al solution dans Visual Studio Ultimate 2010
5) Je build (F6)
6) Je lance un "cmd" dans le dossier debug de la solution et j'éxécute la commande suivante.
edmgen2.exe /ModelGen "Server=127.0.0.1;Port=5432;User Id=postgres;Password=a1b2c3d4;Database=school;" Npgsql school
Et la j'ai une erreur
Voila le debug avec Visual Studio 2010"Unhandled Exception: System.Data.ProviderIncompatibleException: A null was returned after calling the 'GetService' method on a store pr
ovider instance of type 'Npgsql.NpgsqlFactory'. The store provider might not be functioning correctly.
at System.Data.Entity.Design.Common.MetadataUtil.GetProviderServices(DbProviderFactory factory)
at System.Data.Entity.Design.EntityStoreSchemaGenerator.CreateStoreSchemaConnection(String providerInvariantName, String connectionS
tring)
at System.Data.Entity.Design.EntityStoreSchemaGenerator..ctor(String providerInvariantName, String connectionString, String namespac
eName)
at EdmGen2.EdmGen2.ModelGen(String connectionString, String provider, String modelName, Version version, Boolean includeForeignKeys)
in c:\Users\TO101279\Desktop\EdmGen2\EdmGen2\EdmGen2\EdmGen2.cs:line 170
at EdmGen2.EdmGen2.ModelGen(String[] args) in c:\Users\TO101279\Desktop\EdmGen2\EdmGen2\EdmGen2\EdmGen2.cs:line 159
at EdmGen2.EdmGen2.Main(String[] args) in c:\Users\TO101279\Desktop\EdmGen2\EdmGen2\EdmGen2\EdmGen2.cs:line 56".
#### Pour vérifier le fonctionnement simple ####
1) J'ai créé un nouveau projet
2) J'ai ajouter une référence vers Npgsql.dll (Add référence > browse)
3) j'ai fait ceci
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Data; using Npgsql; namespace Npgsql.Connect { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=a1b2c3d4;Database=school;"); conn.Open(); NpgsqlCommand command = new NpgsqlCommand("select * from utilisateur", conn); try { NpgsqlDataReader dr = command.ExecuteReader(); while (dr.Read()){ for (var i = 0; i < dr.FieldCount; i++) Console.Write("{0} \t", dr[i]); Console.WriteLine(); } } finally{ conn.Close(); } } } }
Et la j'ai bien le résultat qui s'affiche dans la console.
Quelqu'un à t'il une piste pour ne plus avoir cette erreur?
Me manque t'il une étape?
Est ce normal que malgré le fait que Npgsql soit dans le GAC, il faut que j'ajoute une référence dans mon projet?
Partager