EntityContainerMapping 項目 (MSL)
對應規格語言 (MSL) 中的 EntityContainerMapping 項目會將概念模型中的實體容器對應至儲存模型中的實體容器。EntityContainerMapping 項目是 Mapping 項目 的子項目。
EntityContainerMapping 項目可以擁有下列子項目 (依列出的順序):
EntitySetMapping (零或多個)
AssociationSetMapping (零或多個)
FunctionImportMapping (零或多個)
適用屬性
下表描述可套用至 EntityContainerMapping 項目的屬性。
屬性名稱 |
必要 |
值 |
---|---|---|
StorageModelContainer |
是 |
要對應至的儲存模型實體容器名稱。 |
CdmEntityContainer |
是 |
要對應的概念模型實體容器名稱。 |
GenerateUpdateViews |
否 |
True 或 False。如果是 False,則不會產生更新檢視。當您擁有的唯讀對應因為資料可能無法成功來回對應而無效時,這個屬性應該設定為 False。 預設值為 True。 |
範例
下列範例顯示 EntityContainerMapping 項目,它會將 SchoolModelEntities 容器 (概念模型實體容器) 對應至 SchoolModelStoreContainer 容器 (儲存模型實體容器):
<EntityContainerMapping StorageEntityContainer="SchoolModelStoreContainer" CdmEntityContainer="SchoolModelEntities">
<EntitySetMapping Name="Courses">
<EntityTypeMapping TypeName="c.Course">
<MappingFragment StoreEntitySet="Course">
<ScalarProperty Name="CourseID" ColumnName="CourseID" />
<ScalarProperty Name="Title" ColumnName="Title" />
<ScalarProperty Name="Credits" ColumnName="Credits" />
<ScalarProperty Name="DepartmentID" ColumnName="DepartmentID" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="Departments">
<EntityTypeMapping TypeName="c.Department">
<MappingFragment StoreEntitySet="Department">
<ScalarProperty Name="DepartmentID" ColumnName="DepartmentID" />
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="Budget" ColumnName="Budget" />
<ScalarProperty Name="StartDate" ColumnName="StartDate" />
<ScalarProperty Name="Administrator" ColumnName="Administrator" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
<EntityContainerMapping StorageEntityContainer="SchoolModelStoreContainer"
CdmEntityContainer="SchoolModelEntities">
<EntitySetMapping Name="Courses">
<EntityTypeMapping TypeName="c.Course">
<MappingFragment StoreEntitySet="Course">
<ScalarProperty Name="CourseID" ColumnName="CourseID" />
<ScalarProperty Name="Title" ColumnName="Title" />
<ScalarProperty Name="Credits" ColumnName="Credits" />
<ScalarProperty Name="DepartmentID" ColumnName="DepartmentID" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="Departments">
<EntityTypeMapping TypeName="c.Department">
<MappingFragment StoreEntitySet="Department">
<ScalarProperty Name="DepartmentID" ColumnName="DepartmentID" />
<ScalarProperty Name="Name" ColumnName="Name" />
<ScalarProperty Name="Budget" ColumnName="Budget" />
<ScalarProperty Name="StartDate" ColumnName="StartDate" />
<ScalarProperty Name="Administrator" ColumnName="Administrator" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>