Confinity Documentation
  • Latest Version
  • Latest Version
  • Getting Started

    • Introduction
    • Core Concepts
    • Create an Application
    • Glossary
  • Essentials

    • Authentication & SSO
    • Breaking Changes
    • Roslyn Source Analyzers
    • Changelog
    • ConfinityContent
    • ConfinitySelectable
    • Confinity Schedules
    • Data Seeding
    • Development guidelines [WIP]
    • Entity App
    • Entity Form
    • Entity Permissions
    • Frontend Configuration
    • Images
    • Known Issues
    • Localization
    • Migrations
    • Modules [WIP]
    • On-Site Editing
    • Settings
    • Cascade Delete
    • Replication
    • Infrastructure
  • Modules

    • Analytics Module
    • Assets Module
    • Blog Module
    • Cookie Consent Module
    • Forms Module
    • Friendly Captcha (Forms Module )
    • GeoIP Module
    • Htmx
    • Mail Module
    • Mailing Module
    • MediaPlayer Module
    • GoogleMyBusiness Module
    • OpenTelemetry Module
    • Pages Module [WIP]
    • Pattern Library Module
    • SIX Saferpay (worldline) Module
    • Products Module
    • Search Module
    • Wizard Module
  • Guides

    • Create a Custom Entity App Form Element
    • Date and Time
    • Entity Change Listener
    • File Upload / Temp File
    • HTTP security headers
    • conventions [WIP]
    • How to use Confinity with nginx
    • Notifications
    • Nullability
    • Rename Entity
    • Schedules
    • Useful snippets
    • Content Localization
  • Design Guidelines

    • Introduction
    • Page Components
    • Forms Module

Rename Entity

When renaming an entity the entity framework core and Confinity need to know about it. Otherwise the migration throws exceptions like "An item with the same key has already been added. Key: System.Object Item [System.String]" or later the publishing and references do not work.

Follow these steps to prevent any issues. In this example the entity A is renamed to B:

  • Create a IPersistenceConfiguration<A> (if not existing) and add a builder.ToTable("B")
  • Create a migration. You should see the rename of the table A to B.
  • Remove builder.ToTable("B").
  • Rename the entity A to B
  • Create a migration to ensure nothing else changed. The migration should be empty.
  • Update the reference checker by adding this SQL:
    • Up method:
      migrationBuilder.Sql(@"
      update ""ConfinityEntityReference""
      set ""DependentEntityName"" =   'B'
      where ""DependentEntityName"" = 'A';"); // A and B must be the fully qualified name of this type.
      
    • Down method:
      migrationBuilder.Sql(@"
      update ""ConfinityEntityReference""
      set ""DependentEntityName"" =   'A'
      where ""DependentEntityName"" = 'B';");
      
  • Update the replication by adding the following SQL:
    • Up method:
      migrationBuilder.Sql(@"
      // @Todo
      ");
      
    • Down method:
      // @Todo
      
    • Omitting this step causes pending replications to be ignored or will fail.
Prev
Nullability
Next
Schedules