Помогите разобраться, пожалуйста, если кто имеет опыт маппинга.
Просмотрел много всякого материала, но такого наследования не нашел.
Хотя случай вроде бы типичный:
Имеем три таблицы:
firm - базовая таблица фирм - играет роль базового класса
(id, type_firm, short_name, full name ...)
поле type_firm служит для разделения типа фирм:
type_firm="local" - локальная фирма
type_firm="client" - клиентская фирма
...
firm_local - дополнительные поля для локальных фирм
(id_firm, ...)
id_firm - ссылка на firm, отношение 1:1
firm_client - дополнительные поля для клиентских фирм
(id, id_firm, ...)
id_firm - ссылка на firm, отношение 1:1
Определяю три сущности - BaseFirm - абстрактный базовый класс.
FirmLocal, FirmClient - порождены от BaseFirm.
После маппинга пытаюсь выполнить запрос - вылетает в ошибку:
Вот файл SkladModel1.msl
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="skladModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
<EntityContainer Name="skladModelStoreContainer">
<EntitySet Name="firm" EntityType="skladModel.Store.firm" store:Type="Tables" Schema="dbo" />
<EntitySet Name="firm_client" EntityType="skladModel.Store.firm_client" store:Type="Tables" Schema="dbo" />
<EntitySet Name="firm_local" EntityType="skladModel.Store.firm_local" store:Type="Tables" Schema="dbo" />
</EntityContainer>
<EntityType Name="firm">
<Key>
<PropertyRef Name="id" />
</Key>
<Property Name="id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="firm_type" Type="nchar" Nullable="false" MaxLength="10" />
<Property Name="short_name" Type="nvarchar" Nullable="false" MaxLength="70" />
<Property Name="full_name" Type="nvarchar" Nullable="false" MaxLength="255" />
<Property Name="inn" Type="nvarchar" MaxLength="50" />
<Property Name="okonh" Type="nvarchar" MaxLength="50" />
<Property Name="okpo" Type="nvarchar" MaxLength="50" />
<Property Name="post_ind" Type="nchar" MaxLength="15" />
<Property Name="addr" Type="nvarchar(max)" />
<Property Name="name_bank" Type="nvarchar(max)" />
<Property Name="town_bank" Type="nvarchar" MaxLength="50" />
<Property Name="bik" Type="nvarchar" MaxLength="50" />
<Property Name="ras_schet" Type="nvarchar" MaxLength="50" />
<Property Name="kor_schet" Type="nvarchar" MaxLength="50" />
<Property Name="prim" Type="nvarchar(max)" />
<Property Name="ruk" Type="nvarchar" MaxLength="100" />
<Property Name="glav_buh" Type="nvarchar" MaxLength="100" />
</EntityType>
<EntityType Name="firm_client">
<Key>
<PropertyRef Name="id_firm" />
</Key>
<Property Name="id_firm" Type="int" Nullable="false" />
<Property Name="proc_bonus" Type="numeric" Nullable="false" Scale="3" />
<Property Name="margin" Type="money" Nullable="false" />
<Property Name="full_name_u" Type="nvarchar(max)" />
<Property Name="addr_u" Type="nvarchar(max)" />
<Property Name="inn_u" Type="nchar" MaxLength="30" />
</EntityType>
<EntityType Name="firm_local">
<Key>
<PropertyRef Name="id_firm" />
</Key>
<Property Name="id_firm" Type="int" Nullable="false" />
<Property Name="kladov" Type="nvarchar" MaxLength="50" />
</EntityType>
</Schema></edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="skladModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="skladEntities" annotation:LazyLoadingEnabled="true">
<EntitySet Name="firm" EntityType="skladModel.BaseFirm" />
</EntityContainer>
<EntityType Name="BaseFirm" Abstract="true">
<Key>
<PropertyRef Name="id" /></Key>
<Property Type="Int32" Name="id" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Type="String" Name="short_name" Nullable="false" MaxLength="70" FixedLength="false" Unicode="true" />
<Property Type="String" Name="full_name" Nullable="false" MaxLength="255" FixedLength="false" Unicode="true" />
<Property Type="String" Name="inn" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Type="String" Name="okonh" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Type="String" Name="okpo" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Type="String" Name="post_ind" MaxLength="15" FixedLength="true" Unicode="true" />
<Property Type="String" Name="addr" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Type="String" Name="name_bank" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Type="String" Name="town_bank" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Type="String" Name="bik" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Type="String" Name="ras_schet" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Type="String" Name="kor_schet" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Type="String" Name="prim" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Type="String" Name="ruk" MaxLength="100" FixedLength="false" Unicode="true" />
<Property Type="String" Name="glav_buh" MaxLength="100" FixedLength="false" Unicode="true" />
</EntityType>
<EntityType Name="FirmLocal" BaseType="skladModel.BaseFirm">
<Property Type="Int32" Name="id_firm" Nullable="false"/>
<Property Type="String" Name="kladov" MaxLength="50" FixedLength="false" Unicode="true" />
</EntityType>
<EntityType Name="firm_client" BaseType="skladModel.BaseFirm">
<Property Type="Int32" Name="id_firm" Nullable="false"/>
<Property Type="Decimal" Name="proc_bonus" Nullable="false" Precision="18" Scale="3" />
<Property Type="Decimal" Name="margin" Nullable="false" Precision="19" Scale="4" />
<Property Type="String" Name="full_name_u" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Type="String" Name="addr_u" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Type="String" Name="inn_u" MaxLength="30" FixedLength="true" Unicode="true" />
</EntityType>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
<EntityContainerMapping StorageEntityContainer="skladModelStoreContainer" CdmEntityContainer="skladEntities">
<EntitySetMapping Name="firm">
<EntityTypeMapping TypeName="IsTypeOf(skladModel.BaseFirm)">
<MappingFragment StoreEntitySet="firm">
<ScalarProperty Name="id" ColumnName="id" />
<ScalarProperty Name="glav_buh" ColumnName="glav_buh" />
<ScalarProperty Name="ruk" ColumnName="ruk" />
<ScalarProperty Name="prim" ColumnName="prim" />
<ScalarProperty Name="kor_schet" ColumnName="kor_schet" />
<ScalarProperty Name="ras_schet" ColumnName="ras_schet" />
<ScalarProperty Name="bik" ColumnName="bik" />
<ScalarProperty Name="town_bank" ColumnName="town_bank" />
<ScalarProperty Name="name_bank" ColumnName="name_bank" />
<ScalarProperty Name="addr" ColumnName="addr" />
<ScalarProperty Name="post_ind" ColumnName="post_ind" />
<ScalarProperty Name="okpo" ColumnName="okpo" />
<ScalarProperty Name="okonh" ColumnName="okonh" />
<ScalarProperty Name="inn" ColumnName="inn" />
<ScalarProperty Name="full_name" ColumnName="full_name" />
<ScalarProperty Name="short_name" ColumnName="short_name" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(skladModel.FirmLocal)">
<MappingFragment StoreEntitySet="firm_local">
<ScalarProperty Name="kladov" ColumnName="kladov" />
</MappingFragment>
<MappingFragment StoreEntitySet="firm">
<ScalarProperty Name="id_firm" ColumnName="id" />
<Condition ColumnName="firm_type" Value="local" />
</MappingFragment>
</EntityTypeMapping>
<EntityTypeMapping TypeName="IsTypeOf(skladModel.firm_client)">
<MappingFragment StoreEntitySet="firm_client">
<ScalarProperty Name="proc_bonus" ColumnName="proc_bonus" />
<ScalarProperty Name="margin" ColumnName="margin" />
<ScalarProperty Name="full_name_u" ColumnName="full_name_u" />
<ScalarProperty Name="addr_u" ColumnName="addr_u" />
<ScalarProperty Name="inn_u" ColumnName="inn_u" /></MappingFragment>
<MappingFragment StoreEntitySet="firm">
<ScalarProperty Name="id_firm" ColumnName="id" />
<Condition ColumnName="firm_type" Value="client" /></MappingFragment></EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
</edmx:Edmx>
Ругается при компиляции на маппинг типа FirmLocal - пишет, что должны быть определены все ключевые поля
firm.id и firm_local.id
То же самое с маппингом типа FirmClient
Получается, что в производный тип не может маппироваться на несколько таблиц, когда речь идет об иерархии?