Skip to content

StronglyTyped forgein keys generated broken code #3974

Closed

Description

@MeikelLP
[StronglyTypedId(Template.Guid)]
readonly partial struct DocumentId{}

[StronglyTypedId(Template.Guid)]
readonly partial struct SomethingElseId{}

record Document(DocumentId Id, SomethingElseId SomethingElseId);
record SomethingElse(SomethingElseId Id);

will generate

// foreign key
var parameter0 = parameterBuilder.AppendParameter<System.Guid>((document is Document ? ((Document)document).SomethingElseId : default(System.Guid)));
// own id
var parameter3 = parameterBuilder.AppendParameter<System.Guid>((document is Document ? ((Document)document).Id.Value : default(System.Guid)));

which causes a CS1503 Argument type 'conditional expression' is not assignable to parameter type 'System.Guid'

Workaround:
Use GUIDs for foreign keys until fixed

Activity

  1. jeremydmiller commented on Oct 15, 2025

    @jeremydmiller
    Member

    @MeikelLP There's absolutely nothing in the documentation that would suggest that what you just tried would work. I bleeping hate how much work all this strong typed identifier crap has caused us.

    "I take pull requests" here.

    And if you did actually expect someone to fix this for you, you need to add a bit more detail about what exactly you tried to do. Better repro code == quicker fixes.

  2. locked and limited conversation to collaborators on Oct 17, 2025
  3. converted this issue into a discussion #3978 on Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions