Postgres ormlite id not returning

I am getting the following generated sql when trying to insert into postgres which is throwing an error about the duplicated returning syntax. tried versions 5.8 and 5.8.1

Db.Insert(tblPoco, selectIdentity: true);


INSERT INTO "tablename" (..fields...) VALUES (..values...) RETURNING "id" RETURNING "id"

Please post a Minimal Reproducible Example I can run locally to repro the issue please.

This will pretty much show it, just needs a postgrse db

public class Test
        public void Test1()
            var dbFactory = new OrmLiteConnectionFactory(Config.PostgreSqlConfig.ConnectionString, new PostgreSqlDialectProvider());
            using var db = dbFactory.OpenDbConnection();

            using (var capture = new CaptureSqlFilter())
                db.Insert(new TblDto(), selectIdentity: true);
            var id = db.Insert(new TblDto(), selectIdentity: true);
        public class TblDto : IHasId<int>
            public int Id { get; }

[AutoId] is for Guids, use [AutoIncrement] for auto incrementing integer primary keys

FYI it’s easier to log the SQL with:


Can later disable SQL logging with:


This just uses the BeforeExecFilter behind the scenes.

doh! that was it … attribute blindness!

Thanks for the PrintSql tip :+1:

1 Like