Closed uyau closed 1 year ago
Found table with types that allows rewrite the table cofiguration. Bigint will be int8. integer - int4. after replacing HasColumnType() with that types all work fine. https://www.postgresql.org/docs/8.1/datatype.html
Thanks @uyau I'll make sure this gets corrected for the next release.
also small int goes like "int2" and "timestamp without time zone" just "timestamp". Thats all problem types that I had issue with. 4 types. Maybe there can be some more, but not in my db) Don't have time to sit and test it out)
Can you post the PostgresToCSharp
C# file here that you modified so I can see what you changed 👍
@uyau in your <database>.tt
file, approx line 14, do you have your Settings.Database set to PostgreSQL?
Settings.DatabaseType = DatabaseType.PostgreSQL;
@sjh37 I had follow your instruction by installing msi into GAC, after I installed pacage EntityFramework6.Npgsql with that comes all other packages needed like Npgqls and EF... Then I set settings in tt: Settings.DatabaseType = DatabaseType.PostgreSQL; Settings.TemplateType = TemplateType.Ef6; Settings.GeneratorType = GeneratorType.Ef6; Settings.GenerateSeparateFiles = true; And adding connection string in my web.config
Aftet I save tt. And try to run application. First errors to fix:
In generated "MyDbContext.cs" class I have to change
line - 86 "public bool IsSqlParameterNull(NpgsqlParameter param)" to NpgsqlParameter (or maybe add using npgsql, don't remember)
and line 88 "var sqlValue = param.SqlValue;" to param.NpgsqlValue
Then I run application and in first linq I have error with bigint. Next I open every tableConfiguration and in lines like: Property(x => x.Id).HasColumnName(@"Id").HasColumnType("int4").IsRequired() I'm changing "HasColomnType" to int8,int4, int2 and timezone like I sad earlyer. And after that everything works fine for me) That's all steps I did. Nothing more)
This solution worked for .net Framework 4.5 and 4.7. Same sequence in both case
Aftet I save tt. And try to run application. First errors to fix: In generated "MyDbContext.cs" class I have to change line - 86 "public bool IsSqlParameterNull(NpgsqlParameter param)" to NpgsqlParameter (or maybe add using npgsql, don't remember) and line 88 "var sqlValue = param.SqlValue;" to param.NpgsqlValue
Thank you @uyau. This fixed my error with a brand new solution using EF7 Core and .NET Core for PostgreSQL. Definitely a bug that needs to be fixed.
This has been released in v3.8.2. Any problems, please let me know.
The same error for "integer" and date "timestamp without time zone" and maybe more, i didn't go further. Why so, if database have this types?