Search code examples
c#sqliteormormlite-servicestack

ORMLite throws System.ArgumentException with the message "An entry with the same key already exists."


I am currently trying to connect to my SQLite dummy db using ORMLite but unfortunately I constantly get the error thrown.

This is the code I use to connect to my DB:

var debug_string = @"Data Source=.\SQLiteDatabase\Company_DB.db;Version=3;";

string connectionString = debug_string;
IDbConnectionFactory dbFactory = new OrmLiteConnectionFactory(connectionString, SqliteDialect.Provider);

try
{
    using (var dbconn = dbFactory.OpenDbConnection())
    {
    // some code
    }
}
catch (Exception ex)
{
    var message = ex.Message;
    var innerEx = ex.InnerException;

}

As soon as the breakpoint hits the using statement opening the database connection it throws me a System.ArgumentException with the message An entry with the same key already exists.

Does anyone have an Idea what the problem could be?


Solution

  • I found the source of the problem. Seems like version 6.11 of ORMLite is buggy and doesn't work properly. Downgraded the NuGet package to 6.10 and it works like a charm.