How to Implement Strongly Typed IDs with EF Core and ASP.NET Core Razor Pages @zoran-horvat
How to Implement Strongly Typed IDs with EF Core and ASP.NET Core Razor Pages  @zoran-horvat
Uploaded March 2024 | Updated September 2026, 3 weeks ago
Check out Dometrain and use code ZORAN for 15% off any course ► dometrain.com/?coupon_code=ZORAN

Become a sponsor to access source code ► patreon.com/zoranhorvat
Join Discord server with topics on C# ► codinghelmet.com/go/discord
Enroll course *Beginning Object-Oriented Programming with C#* ► codinghelmet.com/go/beginning-oop-with-csharp
Subscribe ► youtube.com/channel/UCxsWfh8LCcn55mFB6zGBT1g?sub_confirmation=1

Related videos:
How DDD Makes OOD More Powerful ► youtu.be/W2OobtTQo9Y
Learn To Love DDD-Style Strongly Typed IDs ► youtu.be/hW-7lkuD-Cc
Validating Records in C# ► youtu.be/MUriDSrN_TY
The Lesson About GUID IDs I Learned the Hard Way ► youtu.be/n17U7ntLMt4

Do you pass strings and ints around your application? Nah, that's a primitive obsession!
Do you exchange enums between classes? Nah, that's an anemic domain model!
Then, why would one send raw ID values between classes and to the UI? Those raw IDs look that way because the database is fine with them, not because they are good in the domain model!
This video dissects the problem of ensuring strong typing when assigning ID values through all the application layers: in Entity Framework Core mappings, in the domain model and all the calls inside it, to Razor pages and HTML generation.
You will learn how to work with autoincrement numbers, common GUIDs, and lexicographically sortable UUIDs, each separately wrapped into a strong ID type that preserves assignment safety, including model binding to and from HTML.

⌚ 00:00 Intro
⌚ 01:14 Implementing a strong ID
⌚ 06:51 Mapping to EF Core and Razor pages
⌚ 10:55 Strongly typed model binding
⌚ 12:48 Using sortable UUIDs
⌚ 14:48 Using autoincrement IDs
⌚ 15:45 Demonstrating strongly typed IDs
⌚ 16:56 Outro

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
⚡️COPYRIGHT NOTICE:
The Copyright Laws of the United States recognize a “fair use” of copyrighted content. Section 107 of the U.S. Copyright Act states: “Notwithstanding the provisions of sections 106 and 106A, the fair use of a copyrighted work, including such use by reproduction in copies or phono records or by any other means specified by that section, for purposes such as criticism, comment, news reporting, teaching (including multiple copies for classroom use), scholarship, or research, is not an infringement of copyright." This video and our youtube channel, in general, may contain certain copyrighted works that were not specifically authorized to be used by the copyright holder(s), but which we believe in good faith are protected by federal law and the Fair use doctrine for one or more of the reasons noted above.

#csharp #dotnet #entityframeworkcore
How to Implement Strongly Typed IDs with EF Core and ASP.NET Core Razor PagesValidating Records in C#: Everything You Ever Wanted To Know but Had No One To AskPlanning Mode is a Dangerous IllusionClaude Will Fail This Task - 100% GuaranteedLearn an Algorithm in 60 Seconds! - ShufflePrevent GitHub Copilot Hallucinations With This Prompting TechniqueMaster The L in SOLID3 Shocking Misconceptions Among C# ProgrammersC# Records Are Functional - Use Them That Way!C# Constructors Just Got Better!How Do You Cancel an async Method? | Step-by-Step TutorialThe Real Story Behind C# 15 Union Types
Zoran on C# |

How to Implement Strongly Typed IDs with EF Core and ASP.NET Core Razor Pages

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER