msawczyn / EFDesigner2022

Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
MIT License
123 stars 21 forks source link

How Generate a GUID as PK? #79

Closed MyKeySoftMK closed 12 months ago

MyKeySoftMK commented 1 year ago

By default a autoincrement int64 is set as PK for every Entity.

In my design i will use Guids as PK - so it easier to combine online/offline DB.

Now i set the property as follows: Database Default Value: newid() Identity Type: AutoFenerated Type: Guid

Is it correct so? I missing in the created Table on the SQL-Server the 'newid()'-Command

BlackPuddingERP commented 12 months ago

Don't you think it doesn't make sense for the entity to be Autogenerated (created by the database) and at the same time try to create it yourself in the Database default value?

msawczyn commented 12 months ago

EFCore will take care of that for you. Please see https://learn.microsoft.com/en-us/ef/core/