Last post Apr 25, 2013 08:21 AM by Larry Watson
Apr 22, 2013 10:46 AM|Larry Watson|LINK
I am receiving and error 3014 "Problem in mapping fragments starting at lines 2206, 2213:The foreign key 'Foreign key constraint" when I do a second level of inheritance. I am using database first approach. Here is the scenario:
Base class: Person (Id, name,...)
class: Employee (Id, title, login, pw,....) - inherits from Person
class: Therapist (Id, License, rate,.....) - inherits from Employee
I remove the associations, remove Id from Employee and Therapist, check the table mappings, validate and get the error. I have several TPT's defined but this is the only one with errors and is also the only one that has a second level of "is a"
Please help point out the error in my approach and how to correct it.
Apr 23, 2013 04:43 AM|Pengzhen Song - MSFT|LINK
create a TPT mapping by using ToTable() method:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
For detailed information, you can refer here
Hope it can help you
Apr 25, 2013 08:21 AM|Larry Watson|LINK
Thanks for your quick response. The links you provided are exactly where I learned about building the TPT model. The issue seems to occur where there is a 2nd level of inheritance:
Therapist "is a" employee "is a" person. Employee creates with no issue. Therapist seems to throw the 3014 error. Are you suggesting to write the code rather than let the model generate it? I will give it a try.