That helped. Results are a bit strange though. Seems to be related to the UniqueConstraints attribute.
This works:
[UniqueConstraint(nameof(Environment), nameof(Name))]
public class User2
{
[AutoId]
public Guid Id { get; set; }
public Guid Environment { get; set; }
public string Name { get; set; }
}
This doesn’t:
[UniqueConstraint(nameof(Environment), nameof(Name))]
public class User
{
[AutoId]
public Guid Id { get; set; }
public Guid Environment { get; set; }
public string Name { get; set; }
}
Only difference is name of class. Seems that OrmLite is producing some malformed SQL for the CONSTRAINT name when class name is User:
CREATE TABLE "user"
(
"id" UUID PRIMARY KEY DEFAULT (uuid_generate_v4()),
"environment" UUID NOT NULL,
"name" TEXT NOT NULL,
CONSTRAINT UC_"user"_Environment UNIQUE ("environment")
);
Notice the quotes around the user value in the constraint? Postgres doesn’t seem to like this.
User2 produces:
CREATE TABLE "user2"
(
"id" UUID PRIMARY KEY DEFAULT (uuid_generate_v4()),
"environment" UUID NOT NULL,
"name" TEXT NOT NULL,
CONSTRAINT UC_user2_Environment UNIQUE ("environment")
);
So I thought, maybe because the class file name was also User.cs. So I changed it to User2.cs, but same issue.
So it seems that for whatever reason OrmLite is adding quotes around “user” in the constraint, but not around “user2” in the constraint. Very odd. When I remove the constraint attribute, user works.
Is this something that can be fixed?