Open afust003 opened 3 years ago
Try using the msi installer from https://github.com/npgsql/npgsql/releases/tag/v4.1.8
The generator is a T4 template that runs externally to your project, and therefore cannot make use of any nuget packages you have installed into your project. It can however use ones that are installed in the GAC. The wiki article is a bit thin and I need to flesh it out fully as you are not the only person who has had the same problem.
@afust003 I have updated the documentation in https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/wiki/PostgreSQL
Let me know how you get on.
Thank you Simon! Installing the MSI for 4.1.8 (https://github.com/npgsql/npgsql/releases/tag/v4.1.8) helped the T4 engine to discover the provider and allowed me to reverse engineer the postgres DB with EFCore.
The following are a few concerns extra concerns that come to mind with this work-around:
If some of this doesn't make sense, let me know and I can try to better explain.
Thanks, -Alex
Hi @afust003
npgsql
and manually update your machine.config
file.npgsql
is registered in the GAC, as long as the SQL it uses against the database returns the same expected data.npgsql
you want within your own solution. They should be independent. Try registering the same version of the npgsql
you are using in your solution and manually update your machine.config
file. That way there can't be any discrepancies, and no accidental use of the GAC npgsql
in your running solution.I had the same issue and what did the trick for me was during the installation of the msi package you linked, I had to select the GAC option during installation because doing it manually with the developer command line did not work.
I have Some things to mention in addition to this:
Using npgsql, Version=4.1.3.1, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL
as a provider, makes the reverse-poco create a Context with UseSqlserver( ) and with a wrong: using Microsoft.Data.SqlClient; statements.
As the image below shows, it also adds SqlParameters.
In addition to this by registering another provider in GAC:
npgsql, Version=5.0.7.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL
and by replacing the 4+ version with the 5+ in the machine.config file the reverse poco fails to generate the context. It only works with:
npgsql, Version=4.1.3.1, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7, processorArchitecture=MSIL
Anyway, all the above are quickly fixed by manually fixing the context file but I just wanted to report them just in case.
@andreabertanzon, are you saying you were able to get the v5 to work? @andreabertanzon and @sjh37, I tried manually registering v5 in the GAC + updating machine.config to point to v5 but wasn't able to get RPG to work with v5 for reverse-engineering database. Again, my concern is code-first migration and RPG process parity divergence. That is failing to get RPG to work with npgsql v5 driver the same way we are using npgsql v5 for migrations.
@afust003 I've never used v5, and have v4 installed which I know works ok.
Hi Simon,
I have a .NET CORE 5 project with a .tt file targeting "Settings.DatabaseType= DatabaseType.PostgreSQL;" and trying to use EfCore5 v5.0.6 to create DBContext + Domain classes from an existing postgres database. The .tt generation process fails with the following error:
The following link does not provide enough information to get the .tt to recognize postgres Provider: https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/wiki/PostgreSQL
I've even tried to register the npgsql.dll (that is installed as Nuget package into the same project) but this doesn't really help. There's also a confusing discussion here (https://www.npgsql.org/doc/installation.html) about Windows MSI Installer prior to Npgsql 5.0.0 but leaves out 5.0.0+ (saying we should use the Nuget package); but back to this link (https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/wiki/PostgreSQL) it agains mentions the GAC.
//tried cd [user].nuget\packages\npgsql\5.0.5\lib\net5.0" gacutil.exe /i Npgsql.dll
Could you provide some clarification? Really in a crunch after burning a few days trying to unsuccessfully migrate an EF6 TSqlServer to a EFCore5 postgres backend.
Thanks, -Alex