Open Jenevra opened 3 years ago
Hi @Jenevra, I haven't worked on this project for quite a long time now, but maybe we can figure out a solution for this problem. Could you provide me some information on which EFCore version you are using or maybe even some source code of yours?
Hi!
I've included your PostgreSQL package in my project and now I have a problem and I don't know how to solve it. I've done everything that's in your documentation and have the next error now:
"An error occured: Method 'Translate' in type 'EntityFrameworkCore.Extensions.Sequences.PostgreSQL.Internal.NpgsqlSequenceTranslator' from assembly 'EntityFrameworkCore.Extensions.Sequences.PostgreSQL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation."
I've also opened your test project and everything works fine and looks the same as in my project.
Maybe you may have some ideas why it doesn't work.
Thanks.
I'm facing the same issue. Did you find a solution for this?
@cojocaru-dragos-alexandru Could you provide some details about the EFCore version you are using in your application? My guess would be that IMethodCallTranslator of EFCore 3.1 is not compatible with higher EFCore versions.
I'm using EFCore 5. I just pulled the project, upgraded to EFCore5 and sure enough as you said, the Translate method requires an extra parameter IDiagnosticsLogger<DbLoggerCategory.Query> logger
. Also in the NextValueExpression.cs, the print method is now protected and the expressionPrinter.VisitList seems to be now VisiCollection.
How do you propose to integrate these changes?
Thanks for the prompt response.
Hi! I've included your PostgreSQL package in my project and now I have a problem and I don't know how to solve it. I've done everything that's in your documentation and have the next error now:
"An error occured: Method 'Translate' in type 'EntityFrameworkCore.Extensions.Sequences.PostgreSQL.Internal.NpgsqlSequenceTranslator' from assembly 'EntityFrameworkCore.Extensions.Sequences.PostgreSQL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation."
I've also opened your test project and everything works fine and looks the same as in my project. Maybe you may have some ideas why it doesn't work. Thanks.
I'm facing the same issue. Did you find a solution for this?
Hi!
Actually, I didn't have a lot of time when I created this issue:( and I completely forgot about it. So, I came up with a custom solution. It's not good like this one, but I can share it if you want, and the owner won't mind, of course.
It's not good like this one, but I can share it if you want, and the owner won't mind, of course.
Feel free to share whatever you got.
public static class DbContextSequenceExtensions
{
public static async Task<T> GetSequenceNextValue<T>(this DbContext db, string name)
{
var dbType = GetDbType(typeof(T));
var result = new NpgsqlParameter("result", dbType)
{
Direction = ParameterDirection.Output
};
var nameParameter = new NpgsqlParameter("@name", NpgsqlDbType.Text)
{
Direction = ParameterDirection.Input,
Value = name
};
var sql = "SELECT nextval(@name) AS result";
await db.Database.ExecuteSqlRawAsync(sql, nameParameter, result);
return (T) result.Value;
}
private static NpgsqlDbType GetDbType(Type type)
{
// we needed only long type now but you can add others
if (type == typeof(long))
{
return NpgsqlDbType.Bigint;
}
throw new NotSupportedException($"Numeric type '{type.Name}' not supported");
}
}
Yeah, it's a really obvious solution, but it helped :)
@moritzrinow Hello, can PostgreSQL be updated to the latest version? Thank you
Hi!
I've included your PostgreSQL package in my project and now I have a problem and I don't know how to solve it. I've done everything that's in your documentation and have the next error now:
I've also opened your test project and everything works fine and looks the same as in my project.
Maybe you may have some ideas why it doesn't work.
Thanks.