Store generated Guid as key does not work on Azure

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
mover
Posts: 1
Joined: Wed 15 Jan 2014 16:53
Location: Netherlands

Store generated Guid as key does not work on Azure

Post by mover » Wed 15 Jan 2014 17:10

I am using Entity Developer 5.5 with EF 5 and an Azure MS SQL database. SQL Server/Azure is set in the model properties as the target server/version.
I want to use GUIDs as a primary key, and the keys should be generated by the database. However, when doing this, Entity Developer generates SQL statements with the function "newsequentialid()". This function is not supported on Azure.
How can I tell Entity Developer to use the "newid()" function, which is supported?

strandedpirate
Posts: 21
Joined: Tue 07 Jan 2014 12:38

Re: Store generated Guid as key does not work on Azure

Post by strandedpirate » Wed 15 Jan 2014 21:50

Which template are you using?

Try setting the Store Generated Pattern property for that column in Entity Developer to Identity and over in sql server management studio set a default value for that column of newid()

Sql Server Management Studio:

Image

Entity Developer:

Image

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

Re: Store generated Guid as key does not work on Azure

Post by Shalex » Thu 16 Jan 2014 12:28

We have reproduced the issue: if Model Settings > Synchronization > Mapping > Server Version is set to Azure, the Generate Database Script and Update To Database wizards of Entity Developer generate "DEFAULT NEWSEQUENTIALID()" for the property with Nullable=False, Store Generated Pattern=Identity, Type=Guid (in SSDL: Type=uniqueidentifier). We will notify you when the problem is fixed.

As a temporary workaround, please set Default Value=newid() for the storage column explicitly in the Store (SSDL) part of the model. Entity Developer allows to modify the Storage part of the model in design time: you can navigate to the storage column in Model Explorer OR select entity property > right click > Select Storage Object.

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

Re: Store generated Guid as key does not work on Azure

Post by Shalex » Mon 27 Jan 2014 10:25

The bug with generating NEWID() by Generate Database Script/Update Database From Model wizards for non-nullable Guid Identity property when 'Server Version=Azure' is fixed. We will notify you when the corresponding build of Entity Developer is available for download.

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

Re: Store generated Guid as key does not work on Azure

Post by Shalex » Thu 30 Jan 2014 16:00

New build of Entity Developer 5.7.286 is available for download!
It can be downloaded from http://www.devart.com/entitydeveloper/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=32&t=28822.

Post Reply