After upgrade of .net core to v3 and npgsql to v3 I am getting strange error:
System.Exception: Error trying to fetch w/ sql 'SELECT schemaname, relname FROM pg_stat_user_tables WHERE relname LIKE ? AND schemaname = ANY(?);'
---> System.MissingMethodException: Method not found: 'Npgsql.NpgsqlDataReader Npgsql.NpgsqlCommand.ExecuteReader()'.
at Marten.Util.CommandExtensions.Fetch[T](NpgsqlCommand cmd, String sql, Func`2 transform, Object[] parameters)
at Marten.Storage.TenantExtensions.<>c__DisplayClass4_0`1.<Fetch>b__0(NpgsqlConnection conn)
--- End of inner exception stack trace ---
at Marten.Storage.TenantExtensions.<>c__DisplayClass4_0`1.<Fetch>b__0(NpgsqlConnection conn)
at Marten.Storage.TenantExtensions.execute[T](ITenant tenant, Func`2 func)
at Marten.Storage.TenantExtensions.Fetch[T](ITenant tenant, String sql, Func`2 transform, Object[] parameters)
at Marten.Schema.DbObjects.SchemaTables()
at Marten.Schema.DocumentCleaner.CompletelyRemoveAll()
at CryptoAnalysis.Auth.Api.Startup.InitializeDatabase() in /src/CryptoAnalysis.Auth.Api/Startup.cs:line 207
at CryptoAnalysis.Auth.Api.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in /src/CryptoAnalysis.Auth.Api/Startup.cs:line 179
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()
Any ideas why?
MissingMethodException is always from mismatched assemblies. In this case you're using an incompatible version of Npgsql.
I am using last version of npgsql. Are you compatible with last version of npgsql?
Npgsql 4.1 had breaking API changes from 4.0, so no. If you want to continue using Marten, roll Npgsql back to before Npgsql 4.1. The latest Marten locks in the Nuget version range to prevent this. And longer term we're working w/ the Npgsql team to get things sorted out.
@senzacionale could you try again with Marten version 3.8.1?
Still the same error with v3.8.1
System.Exception: Error trying to fetch w/ sql 'SELECT schemaname, relname FROM pg_stat_user_tables WHERE relname LIKE ? AND schemaname = ANY(?);'
---> System.MissingMethodException: Method not found: 'Npgsql.NpgsqlDataReader Npgsql.NpgsqlCommand.ExecuteReader()'.
Issues should be solved by this release
https://github.com/npgsql/npgsql/releases/tag/v4.1.1
@senzacionale could you try it with https://www.nuget.org/packages/Marten/3.9.0 it's using NpgSql 4.1.1
It is working now. Bug fixed!
@senzacionale great! Thank you for the feedback 馃憤
Thank you for all the support.
Most helpful comment
Thank you for all the support.