I'm testing with 15.1 XPO accessing a PostgreSQL 9.2 database. I have a table defined as follows:
SQLCREATE TABLE public.a_prueba (
id SERIAL,
nombre VARCHAR(20),
apellido VARCHAR(20),
edad INTEGER,
CONSTRAINT a_prueba_pkey PRIMARY KEY(id)
) WITH OIDS;
I proceed to add a new item with DevExpress ORM Data Model Wizard
generating the following code :
C#public partial class a_prueba : XPLiteObject
{
int fid;
[Key]
public int id
{
get { return fid; }
set { SetPropertyValue<int>("id", ref fid, value); }
}
string fnombre;
[Size(20)]
public string nombre
{
get { return fnombre; }
set { SetPropertyValue<string>("nombre", ref fnombre, value); }
}
string fapellido;
[Size(20)]
public string apellido
{
get { return fapellido; }
set { SetPropertyValue<string>("apellido", ref fapellido, value); }
}
int fedad;
public int edad
{
get { return fedad; }
set { SetPropertyValue<int>("edad", ref fedad, value); }
}
}
As can be seen, the wizard generates the id field as [key] instead of generating it as [Key (true)].
In the Data Model Designer, the property "Is Identity" is generated as "False". In a small database, just change the property to true; but in a database with lots of tables, maintenance is difficult, and even worse when using the "Update Model from Database" option, all changes made are lost.
How to avoid this loss? or better yet how to make the Wizard generates the "Is Identity" property to "True" in these cases with auto-incrementing key fields.
The situation is the same in the case of creating a table without OIDs.
SQLCREATE TABLE public.a_prueba2 (
id SERIAL,
nombre VARCHAR(20),
apellido VARCHAR(20),
edad INTEGER,
CONSTRAINT a_prueba2_pkey PRIMARY KEY(id)
) WITHOUT OIDS;
Thanks
Fernando
Hello Fernando.
Thank you for your report. The current version of PostgreSqlConnectionProvider doesn't detect auto-incrementing columns. We will consider this functionality for future updates of our components.
Ok, keep waiting with each release of DevExpress this functionality, for now I will continue with the Entity Framework … the more I see my project grows more distant the possibility of buying and migrate XPO; Details like this make me wonder about a possible migration.
Thank you.
Thank you for your feedback, Fernando.