With the new #dotnet project I've gone all in with value types, even using custom type for entity IDs.

record struct Id<T>(long Value)

It's better for type safety (can't mix IDs of different entities) and also for type inference.

If only #csharp had proper type aliases, so I could define UserId = Id<User>! global using helps, but it's still only project-specific. I want to write code generator that generates those global usings.

As an update, I made sample project for those "generic strong IDs": https://github.com/jukkahyv/dotnet-entity-id

That includes Roslyn code generator for global usings (global using OrderId = Id<Order>). I've been using those for a while now, and it works.

GitHub - jukkahyv/dotnet-entity-id: Sample for strongly typed entity ID value types for .NET

Sample for strongly typed entity ID value types for .NET - jukkahyv/dotnet-entity-id

GitHub