-
Notifications
You must be signed in to change notification settings - Fork 255
Description
This is using the feature where some properties of an entity are mapped to a different table.
The core of the problem is that PK constraint names need to be unique in Postgres. The way that EF generates the PK constraint names results in conflicts when creating the database using EnsureCreated. There appears to be no way to mitigate this due to the way that names are generated.
The EnsureCreated path ends up calling RelationalKeyExtensions.GetName to get the name of the PK constraint. Because both the primary and split mapping have the same entity, and thus the same PrimaryKey, the name of the PK ends up identical on both tables, and the available override via annotation applies to the key, not the StoredObject. The net effect is that EF always creates the same name for both PK constraints, which fails as it's not unique.
The pgcontext.Database.Migrate path does not have the same issue, and there are multiple ways to customize the names.
The lack of a workaround is that there are no injection points to modify the name of the constraint at creation time, and the code doesn't allow for a table/StoredObject scoped constraint name.
I can provide sample code if that would help.