Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity Framework 4.0 Creating a new entity derived from other entities
    text
    copied!<p>I currently have a complex entity relationship setup based on my data structure in sql server 2008. </p> <p>What I'm trying to do I would think would be ridiculously simple but I'm pulling my hair out and have spent days trying to figure it out.</p> <p>I have an Address and AddressType table which are joined on addressTypeID. There are 2 AddressTypes, "Billing" and "Shipping". I'd like to be able to create a custom entity for both Billing and Shipping. I would have thought I could just inherit from the Address entity and add a condition to that to retrieve the correct type but its not as simple as that.</p> <p>I do not want to remove the navigation properties or fields from these existing entities so that we can dive into those pre-existing entities if need be.</p> <p>The goal is to create custom entities that contain fields from other entities based on certian criteria... almost like what a view does for SQL server. Literally all of the examples I found on the internet are not clear on how to do this.</p> <p>What I have right now is Table per Concrete type (I believe). Everytime I try to do this vs yells at me telling me that things arent mapped etc... and I map them then get a new error message. Are there any good tuturials out there that are clear? I'd rather not dive into the ssdl, etc since those would get overwritten when I rebuild my model.</p> <p>lazy loading is disabled... thats how I want it.</p> <p>Why can't I just create a new entity, copy and paste the fields and set the table mapping? I created a new entity called BillingAddress, copied the fields from Address and set the table mapping.... then I get the error:</p> <p>Error 297 Error 3033: Problem in mapping fragments starting at line 4525:EntitySets 'BillingAddresses' and 'Addresses' are both mapped to table 'Address'. Their primary keys may collide.</p> <p>I also tried inheriting from the Address table.... error: must specify mapping fror all types in Set Addresses</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload