PREFACE: I think this is a bug in the EF code base but I'm open to suggestions for a change in my model as well.
The Error:
When EF Code First attempts to build my model, I get the exception: The operation failed because an index or statistics with name 'IX_LotInventoryItemTypeId_ProductId' already exists on table 'dbo.Inventory'.
The Data Models:
I am developing a custom inventory system which includes models:
InventoryBase, ChileInventory, PackagingInventory
ProductBase, ChileProduct, PackagingProduct
The inventory tree is utilizing TPT inheritance such that InventoryBase => dbo.Inventory, ChileInventory => dbo.ChileInventory, PackagingInventory => dbo.PackagingInventory
The product tree is utilizing TPC inheritance. All derived product types contain the same primary key properties as the base class.
It appears that, since the InventoryBase class defines navigation properties to the derivatives of ProductBase EF is trying to create multiple indexes for the foreign key properties. Below are diagrams of the inventory and product class trees. Does anyone see something I'm missing? Do you see a flaw in the structure of my models or does this appear to actually be a EF bug?
Thanks!