Using Guids for PK fields

Entity Framework v5 and v6

When a guid is used as the type of a field which is part of the Identitying fields of an entity definition, and the guid is generated in the target database, the field setting ForcedStoreGeneratedPatternValue has to be set to Identity to force Entity Framework to obtain the value from the DB.

If this setting on the field is set to its default 'None', the guid value has to be set in code manually prior to saving the entity.

The setting is available in the entity editor, Code generation info tab, select the field to set the setting on. You can also set this setting in bulk on multiple fields at once using the Bulk Element Setting Manipulator tool from the toolbar in the LLBLGen Pro designer.

Entity Framework v1 and v4

When a Guid is used as the type of a field which is part of the Identifying fields of an entity definition, the field isn't registered as an identity field in the CSDL and SSDL parts of the generated Edmx file. This is different from the EF designer.

To set the primary key field of an entity class in your code, you has to assign a normal new Guid value to the field, like with any other primary key field which has a different type. If the field has a default of NEWID() or NEWSEQUENTIALID(), it's ignored by the LLBLGen Pro designer.