{"id":27026982,"url":"https://github.com/bhazel/typed-id","last_synced_at":"2026-05-14T12:33:10.832Z","repository":{"id":189401091,"uuid":"680492375","full_name":"BHazel/typed-id","owner":"BHazel","description":"Strongly-typed IDs for your entities!","archived":false,"fork":false,"pushed_at":"2023-12-26T16:39:34.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-08T20:07:03.203Z","etag":null,"topics":["dotnet"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BHazel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-08-19T12:23:15.000Z","updated_at":"2023-08-19T20:26:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"dec419a9-77dd-4941-a67f-3f34eac872a4","html_url":"https://github.com/BHazel/typed-id","commit_stats":null,"previous_names":["bhazel/typed-id"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BHazel/typed-id","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BHazel%2Ftyped-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BHazel%2Ftyped-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BHazel%2Ftyped-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BHazel%2Ftyped-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BHazel","download_url":"https://codeload.github.com/BHazel/typed-id/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BHazel%2Ftyped-id/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33025023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet"],"created_at":"2025-04-04T23:16:43.138Z","updated_at":"2026-05-14T12:33:10.795Z","avatar_url":"https://github.com/BHazel.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typed ID\n\nA library for strongly-typed IDs for your entities!\n\n## Using Typed IDs\n\n\u003e Typed IDs are available in the **BWHazel.TypedId** NuGet package.\n\nA typed ID is a generic type which is associated with an entity, for example with the `Person` and `Address` types below.  Notice how each of the IDs is tied to a specific entity type.\n\n```csharp\nusing BWHazel.Data;\n\npublic class Person\n{\n    public Uuid\u003cPerson\u003e PersonId { get; set; }\n    public Uuid\u003cAddress\u003e AddressId { get; set; }\n}\n\npublic class Address\n{\n    public Uuid\u003cAddress\u003e AddressId { get; set; }\n}\n```\n\nThese typed IDs can be used in methods:\n\n```csharp\npublic bool IsAddressFor(Uuid\u003cPerson\u003e personId, Uuid\u003cAddress\u003e addressId) { }\n```\n\nThese strongly typed IDs will ensure that IDs for different entities will not get confused.  For this example, if the `Person` and `Address` IDs were swapped in the method call then it would result in a compile-time error.\n\nAdditionally, each type can be implicitly interconverted between and comapred with the underlying ID type, for example the `Uuid\u003cT\u003e` type uses a GUID:\n\n```csharp\nUuid\u003cPerson\u003e personId = person.Id;\nGuid personIdAsGuid = personId;\n\nbool idEqualsGuid = personId == personIdAsGuid;\nbool guidDoesNotEqualId = personIdAsGuid != personId;\n```\n\n## Supported Types\n\nCurrently the library supports the following ID types, all in the **BWHazel.Data** namespace.  Please see the detailed documentation, linked in the table below, for more examples.\n\n| ID Type | Typed ID |\n|-|-|\n| [GUID](docs/uuid.md) | `Uuid\u003cT\u003e` |\n| [Integer](docs/intid.md) | `IntId\u003cT\u003e` |\n| [String](docs/stringid.md) | `StringId\u003cT\u003e` |\n\n## Use with Entity Framework Core\n\n\u003e Entity Framework Core support for Typed IDs is available in the **BWHazel.TypedId.EntityFrameworkCore** NuGet package.\n\nTo use typed IDs in Entity Framework Core they need to be registered with the database context when creating the model in the `DbContext.OnModelCreating()` method.  A helper method is provided to perform the correct mapping to database types for each typed ID in the **Microsoft.EntityFrameworkCoew** namespace.\n\nUsing the example `Person` and `Address` entities above this would look like the following.  Notice that all uses of a typed ID need to be registered.\n\n```csharp\nprotected override void OnModelCreating(ModelBuilder modelBuilder)\n{\n    modelBuilder.Entity\u003cPerson\u003e()\n        .Property(person =\u003e person.PersonId)\n        .IsTypedUuid();\n\n    modelBuilder.Entity\u003cPerson\u003e()\n        .Property(person =\u003e person.AddressId)\n        .IsTypedUuid();\n\n    modelBuilder.Entity\u003cAddress\u003e()\n        .Property(address =\u003e address.AddressId)\n        .IsTypedUuid();\n}\n```\n\nFor each supported typed ID type, the helper methods are:\n\n| Typed ID | Helper Method |\n|-|-|\n| `Uuid\u003cT\u003e` | `IsTypedUuid\u003cT\u003e()` |\n| `IntId\u003cT\u003e` | `IsTypedIntId\u003cT\u003e()` |\n| `StringId\u003cT\u003e` | `IsTypedStringId\u003cT\u003e()` |\n\nA more generic example can be seen [here](docs/ef-core.md).\n\n## Example Programs\n\nExample programs are included to demonstrate how to use Typed IDs and their Entity Framework Core support.\n\n| Example | Functionality |\n|-|-|\n| [Basic Usage](examples/BWHazel.Data.TypedId.Examples.BasicUsage/README.md) | Creating typed IDs, how they interoperate with other typed IDs and underlying types and strong typing. |\n| [Entity Framework Core](examples/BWHazel.Data.TypedId.Examples.EFCore/README.md) | Using typed IDs with Entity Framework Core. |\n\n## Motivation\n\nIDs provide a unique identifier for entity objects and are often based on GUIDs or integers, e.g. using the example above:\n\n```csharp\npublic class Person\n{\n    public Guid PersonId { get; set; }\n    public Guid AddressId { get; set; }\n}\n\npublic class Address\n{\n    public Guid AddressId { get; set; }\n}\n```\n\nHowever, this could result in runtime errors if the different IDs get confused, for example in the following method:\n\n```csharp\npublic bool IsAddressFor(Guid personId, Guid addressId) { }\n```\n\nWhat if the person and address IDs were passed into the method in the wrong order?  As far as the compiler is concerned, no issue, but at runtime odd behaviour will result.\n\nHence, typed IDs!\n\n## Installation\n\nTyped ID and Entity Framework Core support can be installed from NuGet:\n\n| Feature | NuGet Package |\n|-|-|\n| Typed ID | BWHazel.TypedId |\n| Entity Framework Core Support | BWHazel.TypedId.EntityFrameworkCore |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhazel%2Ftyped-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbhazel%2Ftyped-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhazel%2Ftyped-id/lists"}