If ever you install Npgsql explicitly to version 4.0.2, you will be presented with the following error:
Exception thrown: 'System.NullReferenceException' in Marten.dll: 'Object reference not set to an instance of an object.'
at Marten.Util.TypeMappings.ToDbType(Type type)
at Marten.Schema.DuplicatedField..ctor(EnumStorage enumStorage, MemberInfo[] memberPath)
at Marten.Schema.DocumentMapping.DuplicateField(MemberInfo[] members, String pgType, String columnName)
at Marten.Events.EventQueryMapping..ctor(StoreOptions storeOptions)
at Marten.Storage.StorageFeatures.PostProcessConfiguration()
at Marten.DocumentStore..ctor(StoreOptions options)
at Marten.DocumentStore.For(Action1 configure)
Probably got to do with this line:
https://github.com/JasperFx/marten/blob/eb079897138c62d5d765323769e000d27d9c1667/src/Marten/Util/TypeMappings.cs#L33
Are you using the Marten 3.x alpha version, or the 2.x version?
From the readme:
Note that current stable version of Marten 2.x is compatible with Npgsql 3.x. If you are looking for a Marten version compatible with Npgsql 4.x, you can use the Marten 3.x alpha version available in NuGet and also you can checkout the dev branch.
I'm on 2.x version. Would it be possible to limit this in the nuspec so that version 4 of npgsql does not get automatically installed because of other dependencies?
If you want Npgsql 4.x, you need to use Marten 3.x.
If you mean you're using Marten 2.x and not explicitly referencing Npgsql 4.x, but another dependency _is_, that's not a Marten-related issue. You could try explicitly adding a reference to Npgsql 3.x, but that's not going to work if the package causing your problem requires Npgsql 4+.
I understand that for 2.x only npgsql 3.x. My project isn't referencing a dependency that requires npgsql 4.x. I am not saying it is a marten related issue. What i am saying is that as an improvement, it would be good to configure the Marten so that it prevents npgsql 4.x from getting installed when it is installed. I will submit a PR
OK, I misunderstood - adding some kind of maximum version Nuget constraint seems like a good idea, to me at least :) (I'm not the maintainer, just trying to help out)
Done! I think it adds value as it prevents people like me who missed the documented version restriction from making this mistake. Plus it would immediately show you the issue during adding of the nuget package, especially when you have tons of transitive nuget dependencies in your solution
We know, and it's been a massive PITA for everyone. Your PR went into Marten 2.10.1, and I'm getting 3.0 ready right now
Most helpful comment
Done! I think it adds value as it prevents people like me who missed the documented version restriction from making this mistake. Plus it would immediately show you the issue during adding of the nuget package, especially when you have tons of transitive nuget dependencies in your solution