I have an issue with inheritance that I'm not sure how to solve. Using 2.5 Final, 12/5/2007 release. SQL Server 2005. Adapter scenario.
I have a Countries table and an ECCNLicenseCountries table. The ECCNLicenseCountries table is a 1-to-1 relationship to Countries.
Countries is already populated with a fixed list of country records. The user will be able to select from a list of Countries and create an ECCNLicenseCountry record. At this point, the only field that I have in the ECCNLicenseCountries table is the primary key from the Countries table, although more may be added in further releases.
I'm not sure how to create a new ECCNLicenseCountry record and associate it with an EXISTING CountryEntity master record.
I thought that I would need to fetch the CountryEntity that corresponded to the Country that I am trying to add as an ECCNLicenseCountry and assign it to the ECCNLicenseCountryEntity's CountryEntity property (so that when I saved the new sub-class entity GenPro would put the Country's primary key in the ECCNLicenseCountry table), but that property doesn't exist. However, in the designer, the ECCNLicenseCountry entity does show a CountryEntity property, 1-to-1, under the "Fields on relations" tab. It also shows the proper inheritance hierarchy on the "Inheritance info" tab. So my assumption is that because it is sub-classed from CountryEntity, it just doesn't show up at design time in the generated code. Which brings me back to how to created a sub-classed, inherited entity from an existing master record.
It seems to me that the only way to have done this with entities is to have created a new ECCNLicenseCountry entity, fill in the fields for both CountryEntity (as inherited) and ECCNLicenseCountryEntity and save. Which is what I do under normal circumstances with other sub-classed entities I've done. I've just never had an existing "master" record and needed to add a related record after the fact.
The only way I see to do this now is to do a scalar query to insert the primary key data into the ECCNLicenseCountry table, then fetch the ECCNLicenseCountryEntity. Seems to me this could be a fairly common issue and I'm either missing something or using this in the wrong way?
I hope I'm explaining this well enough to understand... Appreciate any help anyone can give me on this.