Use AddBulkOperationSupport · Issue #75 · PawelGerr/Thinktecture.EntityFrameworkCore · GitHub
Skip to content

Use AddBulkOperationSupport #75

Open

Description

@rbsdotnet

Hello
When I use AddBulkOperationSupport I get this error. In some tables I have DateOnly which is nullable and in some it is not
And I am not using TempTable
I am using the latest version
Please help me to solve the problem

System.InvalidOperationException: 'The table 'TempTables.TempTable1' cannot be used for entity type 'Thinktecture:TempTable:Thinktecture.EntityFrameworkCore.TempTables.TempTable<DateOnly?> (TempTable<DateOnly?>)' since it is being used for entity type 'Thinktecture:TempTable:Thinktecture.EntityFrameworkCore.TempTables.TempTable (TempTable)' and potentially other entity types, but there is no linking relationship. Add a foreign key to 'Thinktecture:TempTable:Thinktecture.EntityFrameworkCore.TempTables.TempTable<DateOnly?> (TempTable<DateOnly?>)' on the primary key properties and pointing to the primary key on another entity type mapped to 'TempTables.TempTable1'.'

Activity

  1. changed the title [-]User AddBulkOperationSupport[/-] [+]Use AddBulkOperationSupport[/+] on Jul 18, 2026
  2. PawelGerr commented on Jul 18, 2026

    @PawelGerr
    Owner

    Thanks for the report!

    Cause: The error occurs when something in your model configuration renames all entity types, for example a naming-convention plugin or a loop over modelBuilder.Model.GetEntityTypes() that calls SetTableName(...)/ToTable(...). AddBulkOperationSupport registers internal entity types such as TempTable<DateOnly> and TempTable<DateOnly?>. A rename based on the CLR type name maps both of them to the same name (TempTable`1), and EF Core then fails model validation with the "no linking relationship" error you posted. The error message in your report contains TempTable`1, which is the CLR reflection name, so I assume you have such a rename in place.

    Fix: Released in 10.4.0-beta03. The internal registrations now use the data-annotation configuration source, so conventions (including naming-convention plugins) can no longer override their table names. Please update and try again.

    One caveat: If you rename tables explicitly in OnModelCreating, for example:

    foreach (var entityType in modelBuilder.Model.GetEntityTypes())
    {
       entityType.SetTableName(entityType.ClrType.Name);
    }

    then explicit configuration still wins by design and the error will remain. In that case, skip the internal entity types in your loop:

    foreach (var entityType in modelBuilder.Model.GetEntityTypes())
    {
       if (entityType.Name.StartsWith("Thinktecture:", StringComparison.Ordinal))
          continue;
    
       entityType.SetTableName(entityType.ClrType.Name);
    }

    If the beta does not resolve the problem for you, please provide a minimal repro.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions