๐Ÿ” ๐—•๐—ฒ๐˜€๐˜ ๐—ฃ๐—ฟ๐—ฎ๐—ฐ๐˜๐—ถ๐—ฐ๐—ฒ: ๐—ถ๐—ป๐˜ ๐˜ƒ๐˜€ ๐—š๐—จ๐—œ๐—— ๐—ณ๐—ผ๐—ฟ ๐—ฃ๐—ฟ๐—ถ๐—บ๐—ฎ๐—ฟ๐˜† ๐—ž๐—ฒ๐˜†๐˜€ ๐—ถ๐—ป ๐—˜๐—ป๐˜๐—ถ๐˜๐˜† ๐—™๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ ๐—–๐—ผ๐—ฟ๐—ฒ

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.

๐Ÿ‘‰ ๐—ช๐—ต๐—ฎ๐˜ ๐—ฑ๐—ผ ๐˜†๐—ผ๐˜‚ ๐—ฝ๐—ฟ๐—ฒ๐—ณ๐—ฒ๐—ฟ ๐—ณ๐—ผ๐—ฟ ๐˜†๐—ผ๐˜‚๐—ฟ ๐—ฝ๐—ฟ๐—ถ๐—บ๐—ฎ๐—ฟ๐˜† ๐—ธ๐—ฒ๐˜†๐˜€ โ€” ๐—ถ๐—ป๐˜ ๐—ผ๐—ฟ ๐—š๐˜‚๐—ถ๐—ฑ? ๐—›๐—ฎ๐˜ƒ๐—ฒ ๐˜†๐—ผ๐˜‚ ๐—ณ๐—ฎ๐—ฐ๐—ฒ๐—ฑ ๐—ฝ๐—ฒ๐—ฟ๐—ณ๐—ผ๐—ฟ๐—บ๐—ฎ๐—ป๐—ฐ๐—ฒ ๐—ผ๐—ฟ ๐˜€๐—ฒ๐—ฐ๐˜‚๐—ฟ๐—ถ๐˜๐˜† ๐˜๐—ฟ๐—ฎ๐—ฑ๐—ฒ-๐—ผ๐—ณ๐—ณ๐˜€ ๐—ถ๐—ป ๐˜†๐—ผ๐˜‚๐—ฟ ๐—ฝ๐—ฟ๐—ผ๐—ท๐—ฒ๐—ฐ๐˜๐˜€?

0
Subscribe to my newsletter

Read articles from Supraja Tangella directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Supraja Tangella
Supraja Tangella