C#C
C#4y ago
sonodan.

Using SQL db to create object ID or application?

I have an application where my records in my DB need to have unique IDs. Should I leave this responsibility to the SQL db to create them or should this be handled on the application side?

If the former, if I insert a new record input the db and it auto-creates its ID, is the best practice to use output SQL command to read that ID value from the DB and attached it to my object in memory?

If the latter, are there any best practice patterns to handle IDs that you recommend?

Thanks in advance!
Was this page helpful?