RowVersion causing OptimisticConcurrencyException when Save new Record

Hi,
I’ve got a model like this:

public class Company : IHasId < long > {
[PrimaryKey]
[AutoIncrement]
public long Id { get; set; }
public ulong RowVersion { get; set; }
public string Description {get;set;}
…}

When I try to save a new company I get a exception.

var company = new Company() {Description = “description”};
db.Save(company);

I get this exception:

Exception of type ‘ServiceStack.Data.OptimisticConcurrencyException’ was thrown.

at ServiceStack.OrmLite.OrmLiteWriteCommandExtensions.UpdateAndVerify[T](IDbCommand dbCmd, Action1 commandFilter, Boolean hadRowVersion) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite\OrmLiteWriteCommandExtensions.cs:line 455 at ServiceStack.OrmLite.OrmLiteWriteCommandExtensions.UpdateInternal[T](IDbCommand dbCmd, Object obj, Action1 commandFilter) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite\OrmLiteWriteCommandExtensions.cs:line 446
at ServiceStack.OrmLite.OrmLiteWriteCommandExtensions.Update[T](IDbCommand dbCmd, T obj, Action1 commandFilter) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite\OrmLiteWriteCommandExtensions.cs:line 425 at ServiceStack.OrmLite.OrmLiteWriteCommandExtensions.Save[T](IDbCommand dbCmd, T obj) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite\OrmLiteWriteCommandExtensions.cs:line 973 at ServiceStack.OrmLite.OrmLiteWriteApi.<>c__DisplayClass35_01.b__0(IDbCommand dbCmd) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite\OrmLiteWriteApi.cs:line 361
at ServiceStack.OrmLite.OrmLiteExecFilter.Exec[T](IDbConnection dbConn, Func2 filter) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite\OrmLiteExecFilter.cs:line 64 at ServiceStack.OrmLite.OrmLiteReadExpressionsApi.Exec[T](IDbConnection dbConn, Func2 filter) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite\OrmLiteReadExpressionsApi.cs:line 17
at ServiceStack.OrmLite.OrmLiteWriteApi.Save[T](IDbConnection dbConn, T obj, Boolean references) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite\OrmLiteWriteApi.cs:line 361

What I’m doing wrong?

Thanks a lot

This doesn’t throw an Exception:

public class Company : IHasId<long>
{
    [AutoIncrement]
    public long Id { get; set; }
    public ulong RowVersion { get; set; }
    public string Description { get; set; }
}

public class OrmLiteTests
{
    private readonly IDbConnectionFactory dbFactory = 
        new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider);
    [Test]
    public void Can_save_row_with_no_RowVersion()
    {
        using var db = dbFactory.Open();
        db.DropAndCreateTable<Company>();
        var company = new Company { Description = "description" };
        db.Save(company);
    }
}

Thanks for the reply.
I checked the db and there was a record with id 0. The Save method then tried to update it.
I remove the record and the method works correctly.