Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

EF Code First generating duplicate index names for base class

$
0
0

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!

 


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>