TPC and Unique Primary Keys
Posted: Fri 24 Aug 2012 16:00
I have a big problem here. EF 5.0 Code First keeps complaining when using TPC inheritance mapping saying:
All objects in the EntitySet 'EntitySet' must have unique primary keys
Even if I make separate sets for the derived types. e.g.:
I do this:
public DbSet<ProviderCompany> ProviderCompanies { get; set; }
public DbSet<Bank> Banks { get; set; }
Both, Bank and ProviderCompany derive from Company base class.
Then I do this:
var c1 = context.ProviderCompanies.ToList();
var c2 = context.Banks.ToList();
I have provider companies and banks with same Ids, and it throws the exception:
All objects in the EntitySet 'TestContext.Companies' must have unique primary keys
though I don't have a set named Companies.
I cannot find the solution, please help.
Thanks,
Giorgi
All objects in the EntitySet 'EntitySet' must have unique primary keys
Even if I make separate sets for the derived types. e.g.:
I do this:
public DbSet<ProviderCompany> ProviderCompanies { get; set; }
public DbSet<Bank> Banks { get; set; }
Both, Bank and ProviderCompany derive from Company base class.
Then I do this:
var c1 = context.ProviderCompanies.ToList();
var c2 = context.Banks.ToList();
I have provider companies and banks with same Ids, and it throws the exception:
All objects in the EntitySet 'TestContext.Companies' must have unique primary keys
though I don't have a set named Companies.
I cannot find the solution, please help.
Thanks,
Giorgi