Page 1 of 1

GUID primary key and "Value Generated": Add

Posted: Wed 26 Jun 2019 15:05
by RobertK
When you import from the database to models, and you have a GUID primary key "Id".
The "value generated" selected value is always "Never"
(Even if you first created the database from model, and then create the models from database again
The "value generated" selected value is always "Never")

Shouldnt primary key be default value generated to "Add"? or at least there should be an option to set primary key value generated to "add"?


Note: If I do not manually assign the primary key with a GUID identitifer, it creates an empty GUID value in the database
#postgres

Re: GUID primary key and "Value Generated": Add

Posted: Tue 02 Jul 2019 17:35
by Shalex
Please create the following table in your database:

Code: Select all

CREATE TABLE tbl 
(
  pkey UUID NOT NULL DEFAULT uuid_generate_v1() , 
  CONSTRAINT pkey_tbl PRIMARY KEY ( pkey )
)
And import it into your EF Core Model (*.efml). Entity Developer should set Value Generated=OnAdd for the Pkey property.

JIC: https://dba.stackexchange.com/questions ... n-postgres