0
votes

After installing Npgsql and Simple.Data.PostgreSql from NuGet, and then using the following code:

var connectionString = ConfigurationManager.ConnectionStrings["runningJournal"].ConnectionString;
var db = Database.OpenConnection(connectionString);
var userId = db.user.Insert(userName: "foo").userId;

I get this exception:

System.TypeLoadExceptionCould not load type 'NpgsqlTypes.BitString'
    from assembly 'Npgsql, Version=3.0.4.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7'.
at Simple.Data.PostgreSql.TypeMap..cctor()

I assume that this is an issue with Simple.Data.PostgreSql since accessing the database from Npgsql works just fine. Is this a bug, or is there some other dependency that I need to manually add? Perhaps something else?

1

1 Answers

2
votes

Npgsql 2.x had an NpgsqlTypes.BitString type which was removed in 3.0, which uses .NET's built-in BitArray. It would seem that the version of Simple.Data.PostgreSql which you're using is compiled against Npgsql 2.x, but somehow you're using Npgsql 3.0 in your project. Make sure you're using Npgsql 2.2.7 and not 3.0.x, and perhaps let the Simple.Data.PostgreSql project know to release a new version which works with Npgsql 3.0.