CodeFirst: DatabaseGeneratedOption.Identity does not work for GUID

CodeFirst: DatabaseGeneratedOption.Identity does not work for GUID

Postby 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
dresel
 
Posts: 18
Joined: Tue 20 Nov 2012 13:38

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

Postby Shalex » Wed 09 Jul 2014 17:06

Thank you for your report. We will investigate the question and notify you about the result.
Shalex
Devart Team
 
Posts: 7777
Joined: Thu 14 Aug 2008 12:44

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

Postby 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?
Thomas Heinze
 
Posts: 10
Joined: Fri 18 Jul 2014 16:42

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

Postby 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
Devart Team
 
Posts: 7777
Joined: Thu 14 Aug 2008 12:44

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

Postby 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/static/uuid-ossp.html.
Shalex
Devart Team
 
Posts: 7777
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL