CodeFirst: DatabaseGeneratedOption.Identity does not work for GUID

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
dresel
Posts: 18
Joined: Tue 20 Nov 2012 13:38

CodeFirst: DatabaseGeneratedOption.Identity does not work for GUID

Post by dresel » Sun 06 Jul 2014 13:18

Hi,

adding [DatabaseGenerated(DatabaseGeneratedOption.Identity)] to a GUID Property does not work. This relates to a not-null constraint violation.

Thanks,
Dresel

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: CodeFirst: DatabaseGeneratedOption.Identity does not work for GUID

Post by Shalex » Wed 09 Jul 2014 17:06

Thank you for your report. We will investigate the question and notify you about the result.

Thomas Heinze
Posts: 10
Joined: Fri 18 Jul 2014 16:42

Re: CodeFirst: DatabaseGeneratedOption.Identity does not work for GUID

Post by Thomas Heinze » Mon 21 Jul 2014 14:46

Hi,

i'm trying the same with Version 7.3.201.6 and nothing happens only

Devart.Data.PostgreSql.PgSqlException: NULL-Werte in Spalte "BerechtigteGuId" verletzt Null-Contraint.

Is there a solution?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: CodeFirst: DatabaseGeneratedOption.Identity does not work for GUID

Post by Shalex » Tue 22 Jul 2014 14:53

Thomas Heinze wrote:Is there a solution?
Please generate guid on the client side. For this, assign Guid.NewGuid() to the guid property in the class constructor.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: CodeFirst: DatabaseGeneratedOption.Identity does not work for GUID

Post by Shalex » Thu 25 Sep 2014 16:29

The behaviour is changed in the new (7.3.254) build of dotConnect for PostgreSQL: the DEFAULT value is generated now for the columns in the database which correspond to System.Guid identity properties in the Code-First/Code-First Migrations functionality.

The exact Default value depends on the config.QueryOptions.NewGuidGenerationMethod configuration option (by default SQL expression is used). Possible values:
  • Default
  • UuidGenerateV1
  • UuidGenerateV1mc
  • UuidGenerateV4
For more information, refer to http://www.postgresql.org/docs/8.4/stat ... -ossp.html.

Post Reply