Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Auto-Increment / New GUIDs in DB Migration #1384


User avatar
0
andry3ag created

When creating new entities, is there any way to specify that an Id should be auto-incremented, or in the case of uniqueidentifier/GUID, invoke NEWID() as a default value?


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can define a base entity class which inherits from Entity<Guid> and set it's id property on constructor to new Guid();

  • User Avatar
    0
    andry3ag created

    What about integer autoincrement?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You dont have to do anyting for integers. It's auto increment by default. Do you have any problem about it ?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    As Halil pointed out, there is also no need to set Guid identity fields. Because it's generated by abp with sequential guid generator.

    It has better performance than regular guid generation.