๐ ๐๐ฒ๐๐ ๐ฃ๐ฟ๐ฎ๐ฐ๐๐ถ๐ฐ๐ฒ: ๐ถ๐ป๐ ๐๐ ๐๐จ๐๐ ๐ณ๐ผ๐ฟ ๐ฃ๐ฟ๐ถ๐บ๐ฎ๐ฟ๐ ๐๐ฒ๐๐ ๐ถ๐ป ๐๐ป๐๐ถ๐๐ ๐๐ฟ๐ฎ๐บ๐ฒ๐๐ผ๐ฟ๐ธ ๐๐ผ๐ฟ๐ฒ

As part of my ๐ฝ๐ฒ๐ฟ๐๐ผ๐ป๐ฎ๐น ๐ฝ๐ฟ๐ผ๐ท๐ฒ๐ฐ๐ โ ๐๐ผ๐ฏ ๐๐ฝ๐ฝ๐น๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป ๐ง๐ฟ๐ฎ๐ฐ๐ธ๐ฒ๐ฟ, I researched which type of primary key is best for database models in .NET Core.
โ
๐ถ๐ป๐
(๐๐ป๐๐ฒ๐ด๐ฒ๐ฟ)
public int Id { get; set; }
โ Better performance (faster indexing, smaller size)
โ Human-readable, cleaner in URLs (
/resume/25
)โ Ideal for small/medium apps with a single DB
โ
๐๐จ๐๐
(๐๐น๐ผ๐ฏ๐ฎ๐น๐น๐ ๐จ๐ป๐ถ๐พ๐๐ฒ ๐๐ฑ๐ฒ๐ป๐๐ถ๐ณ๐ถ๐ฒ๐ฟ)
public Guid Id { get; set; }
โ Unique across systems (great for microservices)
โ Harder to guess in URLs (
/resume/7e0f-...
)โ Better security for public-facing routes
For this project, I'm using int
for IDs (like ResumeFileId
, JobApplicationId
) since it's simple, performant, and fits well for apps using a single database.
๐ ๐ช๐ต๐ฎ๐ ๐ฑ๐ผ ๐๐ผ๐ ๐ฝ๐ฟ๐ฒ๐ณ๐ฒ๐ฟ ๐ณ๐ผ๐ฟ ๐๐ผ๐๐ฟ ๐ฝ๐ฟ๐ถ๐บ๐ฎ๐ฟ๐ ๐ธ๐ฒ๐๐ โ ๐ถ๐ป๐
๐ผ๐ฟ ๐๐๐ถ๐ฑ
? ๐๐ฎ๐๐ฒ ๐๐ผ๐ ๐ณ๐ฎ๐ฐ๐ฒ๐ฑ ๐ฝ๐ฒ๐ฟ๐ณ๐ผ๐ฟ๐บ๐ฎ๐ป๐ฐ๐ฒ ๐ผ๐ฟ ๐๐ฒ๐ฐ๐๐ฟ๐ถ๐๐ ๐๐ฟ๐ฎ๐ฑ๐ฒ-๐ผ๐ณ๐ณ๐ ๐ถ๐ป ๐๐ผ๐๐ฟ ๐ฝ๐ฟ๐ผ๐ท๐ฒ๐ฐ๐๐?
Subscribe to my newsletter
Read articles from Supraja Tangella directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
