Entity Framework 的 edmx xml 文档解析: 如何改变实体对应的物理表

1. 改变 SSML

<edmx:StorageModels>
    <Schema Namespace="cmsModel.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/11/edm/ssdl">
        <EntityContainer Name="cmsModelStoreContainer">
          <EntitySet Name="公司" EntityType="cmsModel.Store.公司" store:Type="Tables" Schema="dbo" />
        </EntityContainer>
        <EntityType Name="公司">
          <Key>
            <PropertyRef Name="gs公司Guid" />
          </Key>
          <Property Name="gs公司Guid" Type="uniqueidentifier" Nullable="false" />
          <Property Name="gsmc公司名称" Type="nvarchar" Nullable="false" MaxLength="50" />
          <Property Name="sc删除" Type="bit" Nullable="false" />
        </EntityType>
      </Schema></edmx:StorageModels>

一共改了三处. EntitySet Name="公司" EntityType="cmsModel.Store.公司"   <EntityType Name="公司">

2. 修改 Mappings

    <edmx:Mappings>
      <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
        <EntityContainerMapping StorageEntityContainer="cmsModelStoreContainer" CdmEntityContainer="cmsEntities">
          <EntitySetMapping Name="GS公司">
            <EntityTypeMapping TypeName="cmsModel.GS公司">
              <MappingFragment StoreEntitySet="公司">
                <ScalarProperty Name="sc删除" ColumnName="sc删除" />
                <ScalarProperty Name="gsmc公司名称" ColumnName="gsmc公司名称" />
                <ScalarProperty Name="gs公司Guid" ColumnName="gs公司Guid" />
              </MappingFragment>
            </EntityTypeMapping>
          </EntitySetMapping>
        </EntityContainerMapping>
      </Mapping>
    </edmx:Mappings>

只修改了一处: <MappingFragment StoreEntitySet="公司">

posted @ 2013-04-18 08:24  Ken-Cai  阅读(1115)  评论(0编辑  收藏  举报