1

我尝试更改实体表名称并遇到错误。我刚刚重命名了TblRecord,因为名称来自表名

这里有什么错误以及如何解决它?


错误 :

+       _innerException {"The specified table does not exist. [ Records ]"} System.Exception {System.Data.SqlServerCe.SqlCeException}

Edmx 文件

<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
  <!-- EF Runtime content -->
  <edmx:Runtime>
    <!-- SSDL content -->
    <edmx:StorageModels>
      <Schema Namespace="Xz.Business.Matches.Store" Alias="Self" Provider="System.Data.SqlServerCe.4.0" ProviderManifestToken="4.0" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
        <EntityContainer Name="XzBusinessMatchesStoreContainer">
          <EntitySet Name="Records" EntityType="Xz.Business.Matches.Store.Records" store:Type="Tables" />
        </EntityContainer>
        <EntityType Name="Records">
          <Key>
            <PropertyRef Name="Record" />
          </Key>
          <Property Name="Record" Type="nvarchar" Nullable="false" MaxLength="100" />
          <Property Name="Relations" Type="nvarchar" MaxLength="450" />
        </EntityType>
      </Schema>
    </edmx:StorageModels>
    <!-- CSDL content -->
    <edmx:ConceptualModels>
      <Schema Namespace="Xz.Business.Matches" Alias="Self" p1:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:p1="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
        <EntityContainer Name="RecordzEntities" p1:LazyLoadingEnabled="true">
          <EntitySet Name="Records" EntityType="Xz.Business.Matches.TblRecord" />
        </EntityContainer>
        <EntityType Name="TblRecord">
          <Key>
            <PropertyRef Name="Record" />
          </Key>
          <Property Name="Record" Type="String" Nullable="false" MaxLength="100" Unicode="true" FixedLength="false" />
          <Property Name="Relations" Type="String" MaxLength="450" Unicode="true" FixedLength="false" />
        </EntityType>
      </Schema>
    </edmx:ConceptualModels>
    <!-- C-S mapping content -->
    <edmx:Mappings>
      <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
        <EntityContainerMapping StorageEntityContainer="XzBusinessMatchesStoreContainer" CdmEntityContainer="RecordzEntities">
          <EntitySetMapping Name="Records">
            <EntityTypeMapping TypeName="Xz.Business.Matches.TblRecord">
              <MappingFragment StoreEntitySet="Records">
                <ScalarProperty Name="Record" ColumnName="Record" />
                <ScalarProperty Name="Relations" ColumnName="Relations" />
              </MappingFragment>
            </EntityTypeMapping>
          </EntitySetMapping>
        </EntityContainerMapping>
      </Mapping>
    </edmx:Mappings>
  </edmx:Runtime>
  <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
  <Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
    <Connection>
      <DesignerInfoPropertySet>
        <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
      </DesignerInfoPropertySet>
    </Connection>
    <Options>
      <DesignerInfoPropertySet>
        <DesignerProperty Name="ValidateOnBuild" Value="true" />
        <DesignerProperty Name="EnablePluralization" Value="True" />
        <DesignerProperty Name="IncludeForeignKeysInModel" Value="True" />
        <DesignerProperty Name="CodeGenerationStrategy" Value="None" />
      </DesignerInfoPropertySet>
    </Options>
    <!-- Diagram content (shape and connector positions) -->
    <Diagrams></Diagrams>
  </Designer>
</edmx:Edmx>

这是 EF5 和 VS12

4

1 回答 1

0

如果您在数据库中重命名表,则需要更新 EDMX 中的映射。错误消息是自我描述的。

如果您无法TblRecord从 edmx 设计器中删除模型并使用新名称重新添加它Record

于 2012-10-21T20:01:05.757 回答