[Alias("tblActualValueDigital")]
public partial class tblActualValueDigital
{
[Required]
public int PointSliceID { get; set; }
[Required]
public DateTime UTCDateTime { get; set; }
[Required]
public short ActualValue { get; set; }
}
Produces in SQLite:
CREATE TABLE "tblActualValueDigital" (
"PointSliceID" INTEGER,
"UTCDateTime" VARCHAR(8000) NOT NULL,
"ActualValue" INTEGER NOT NULL,
PRIMARY KEY("PointSliceID")
);
Is there a way to tell Ormlite in code or via attribute to NOT assign a primary key to field PointSliceID?
You can use the [PrimaryKey] attribute to specify your own, alternatively you can use Id property name and [Alias("PointSliceID")] to map it to the RDBMS PK column name.
If it’s not overridden by [PrimaryKey], [AutoIncrement] for auto assigned ints and [AutoId] for auto assigned UUIDs also can be used to identify primary keys.
This table which I’m modeling doesn’t have a primary key so I don’t want one to be generated at all on that point. I’m assuming since it has ID at the end of the property it thinks that is the primary key.
No it’s a fundamental design of OrmLite that it only supports a single primary key, if it can’t infer the primary key from any of the attributes or Id property name it will assume the first property is the primary key.
In most cases you will still be able to query from the Table in OrmLite but not Create the table without it or use the Insert, Update or Delete APIs which rely on a primary key.