ASP.NET MVC3 Entitiy Framework - 在MetadataWorkspace中不存在指定为此MSL的一部分的EntitySet'x'

时间:2011-09-22 07:36:27

标签: c# asp.net-mvc asp.net-mvc-3 entity-framework edmx

我正在预订系统。

以下查询

    Reservatie r = (from res in entities.Reservaties
    where (res.datum == date && res.tijdslot == time)
    select res).FirstOrDefault();

给我以下错误

  

错误54错误2003:EntitySet'Reserveaties'   MetadataWorkspace中不存在指定为此MSL的一部分。 ... \ WWW \模型\ xxx.edmx

看起来它找不到我的桌子。

edmx文件正确显示我的数据库,我已经好几次了。我检查了MSL并没有看到什么特别的东西。问题是我没有任何线索在哪里寻找问题。

我的集成N2CMS(dinamico包)可能与此有关吗? (它正在使用nHibernate)

知道从哪里开始?

也许edmx是有帮助的

<?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="Model.Store" Alias="Self" Provider="MySql.Data.MySqlClient" ProviderManifestToken="5.1" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
        <EntityContainer Name="ModelStoreContainer">
          <EntitySet Name="arrangementen" EntityType="Model.Store.arrangementen" store:Type="Tables" Schema="xxx" />
          <EntitySet Name="complexen" EntityType="Model.Store.complexen" store:Type="Tables" Schema="xxx" />
          <EntitySet Name="klanten" EntityType="Model.Store.klanten" store:Type="Tables" Schema="xxx" />
          <EntitySet Name="reservaties" EntityType="Model.Store.reservaties" store:Type="Tables" Schema="xxx" />
          <EntitySet Name="reservatiestatussen" EntityType="Model.Store.reservatiestatussen" store:Type="Tables" Schema="xxx" />
        </EntityContainer>
        <EntityType Name="arrangementen">
          <Key>
            <PropertyRef Name="arrangementId" />
          </Key>
          <Property Name="arrangementId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="naam" Type="varchar" Nullable="false" MaxLength="255" />
          <Property Name="beschrijving" Type="text" />
          <Property Name="prijs" Type="decimal" Nullable="false" />
          <Property Name="van" Type="int" />
          <Property Name="tot" Type="int" />
          <Property Name="toegelaten_statussen" Type="varchar" Nullable="false" MaxLength="50" />
        </EntityType>
        <EntityType Name="complexen">
          <Key>
            <PropertyRef Name="complexId" />
          </Key>
          <Property Name="complexId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="naam" Type="varchar" Nullable="false" MaxLength="255" />
          <Property Name="openingsuur" Type="int" Nullable="false" />
          <Property Name="sluitingsuur" Type="int" Nullable="false" />
        </EntityType>
        <EntityType Name="klanten">
          <Key>
            <PropertyRef Name="KlantId" />
          </Key>
          <Property Name="KlantId" Type="bigint" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="voornaam" Type="varchar" Nullable="false" MaxLength="100" />
          <Property Name="achternaam" Type="varchar" Nullable="false" MaxLength="150" />
          <Property Name="email" Type="varchar" Nullable="false" MaxLength="150" />
        </EntityType>
        <EntityType Name="reservaties">
          <Key>
            <PropertyRef Name="reservatieId" />
          </Key>
          <Property Name="reservatieId" Type="bigint" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="klantId" Type="bigint" Nullable="false" />
          <Property Name="datum" Type="date" Nullable="false" />
          <Property Name="tijdslot" Type="int" Nullable="false" />
          <Property Name="complexId" Type="int" Nullable="false" />
          <Property Name="arrangementId" Type="int" />
          <Property Name="statusId" Type="int" Nullable="false" />
          <Property Name="recurringDaily" Type="bit" />
          <Property Name="recurringWeekly" Type="bit" />
          <Property Name="recurringMonthly" Type="bit" />
          <Property Name="recurringYearly" Type="bit" />
        </EntityType>
        <EntityType Name="reservatiestatussen">
          <Key>
            <PropertyRef Name="statusId" />
          </Key>
          <Property Name="statusId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="statusnaam" Type="varchar" Nullable="false" MaxLength="255" />
        </EntityType>
      </Schema>
    </edmx:StorageModels>
    <!-- CSDL content -->
    <edmx:ConceptualModels>
      <Schema Namespace="Model" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
        <EntityContainer Name="ALEntities" annotation:LazyLoadingEnabled="true">
          <EntitySet Name="Arrangementen" EntityType="Model.Arrangement" />
          <EntitySet Name="Complexen" EntityType="Model.Complex" />
          <EntitySet Name="Klanten" EntityType="Model.Klant" />
          <EntitySet Name="Reservaties" EntityType="Model.Reservatie" />
          <EntitySet Name="Reservatiestatussen" EntityType="Model.Reservatiestatus" />
        </EntityContainer>
        <EntityType Name="Arrangement">
          <Key>
            <PropertyRef Name="arrangementId" />
          </Key>
          <Property Name="arrangementId" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
          <Property Name="naam" Type="String" Nullable="false" />
          <Property Name="beschrijving" Type="String" />
          <Property Name="prijs" Type="Decimal" Nullable="false" />
          <Property Name="van" Type="Int32" />
          <Property Name="tot" Type="Int32" />
          <Property Name="toegelaten_statussen" Type="String" Nullable="false" />
        </EntityType>
        <EntityType Name="Complex">
          <Key>
            <PropertyRef Name="complexId" />
          </Key>
          <Property Name="complexId" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
          <Property Name="naam" Type="String" Nullable="false" />
          <Property Name="openingsuur" Type="Int32" Nullable="false" />
          <Property Name="sluitingsuur" Type="Int32" Nullable="false" />
        </EntityType>
        <EntityType Name="Klant">
          <Key>
            <PropertyRef Name="KlantId" />
          </Key>
          <Property Name="KlantId" Type="Int64" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
          <Property Name="voornaam" Type="String" Nullable="false" />
          <Property Name="achternaam" Type="String" Nullable="false" />
          <Property Name="email" Type="String" Nullable="false" />
        </EntityType>
        <EntityType Name="Reservatie">
          <Key>
            <PropertyRef Name="reservatieId" />
          </Key>
          <Property Name="reservatieId" Type="Int64" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
          <Property Name="klantId" Type="Int64" Nullable="false" />
          <Property Name="datum" Type="DateTime" Nullable="false" />
          <Property Name="tijdslot" Type="Int32" Nullable="false" />
          <Property Name="complexId" Type="Int32" Nullable="false" />
          <Property Name="arrangementId" Type="Int32" />
          <Property Name="statusId" Type="Int32" Nullable="false" />
          <Property Name="recurringDaily" Type="Boolean" />
          <Property Name="recurringWeekly" Type="Boolean" />
          <Property Name="recurringMonthly" Type="Boolean" />
          <Property Name="recurringYearly" Type="Boolean" />
        </EntityType>
        <EntityType Name="Reservatiestatus">
          <Key>
            <PropertyRef Name="statusId" />
          </Key>
          <Property Name="statusId" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
          <Property Name="statusnaam" Type="String" Nullable="false" />
        </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="ModelStoreContainer" CdmEntityContainer="ALEntities">
          <EntitySetMapping Name="Arrangementen"><EntityTypeMapping TypeName="Model.Arrangement"><MappingFragment StoreEntitySet="arrangementen">
            <ScalarProperty Name="arrangementId" ColumnName="arrangementId" />
            <ScalarProperty Name="naam" ColumnName="naam" />
            <ScalarProperty Name="beschrijving" ColumnName="beschrijving" />
            <ScalarProperty Name="prijs" ColumnName="prijs" />
            <ScalarProperty Name="van" ColumnName="van" />
            <ScalarProperty Name="tot" ColumnName="tot" />
            <ScalarProperty Name="toegelaten_statussen" ColumnName="toegelaten_statussen" />
          </MappingFragment></EntityTypeMapping></EntitySetMapping>
          <EntitySetMapping Name="Complexen"><EntityTypeMapping TypeName="Model.Complex"><MappingFragment StoreEntitySet="complexen">
            <ScalarProperty Name="complexId" ColumnName="complexId" />
            <ScalarProperty Name="naam" ColumnName="naam" />
            <ScalarProperty Name="openingsuur" ColumnName="openingsuur" />
            <ScalarProperty Name="sluitingsuur" ColumnName="sluitingsuur" />
          </MappingFragment></EntityTypeMapping></EntitySetMapping>
          <EntitySetMapping Name="Klanten"><EntityTypeMapping TypeName="Model.Klant"><MappingFragment StoreEntitySet="klanten">
            <ScalarProperty Name="KlantId" ColumnName="KlantId" />
            <ScalarProperty Name="voornaam" ColumnName="voornaam" />
            <ScalarProperty Name="achternaam" ColumnName="achternaam" />
            <ScalarProperty Name="email" ColumnName="email" />
          </MappingFragment></EntityTypeMapping></EntitySetMapping>
          <EntitySetMapping Name="Reservaties"><EntityTypeMapping TypeName="Model.Reservatie"><MappingFragment StoreEntitySet="reservaties">
            <ScalarProperty Name="reservatieId" ColumnName="reservatieId" />
            <ScalarProperty Name="klantId" ColumnName="klantId" />
            <ScalarProperty Name="datum" ColumnName="datum" />
            <ScalarProperty Name="tijdslot" ColumnName="tijdslot" />
            <ScalarProperty Name="complexId" ColumnName="complexId" />
            <ScalarProperty Name="arrangementId" ColumnName="arrangementId" />
            <ScalarProperty Name="statusId" ColumnName="statusId" />
            <ScalarProperty Name="recurringDaily" ColumnName="recurringDaily" />
            <ScalarProperty Name="recurringWeekly" ColumnName="recurringWeekly" />
            <ScalarProperty Name="recurringMonthly" ColumnName="recurringMonthly" />
            <ScalarProperty Name="recurringYearly" ColumnName="recurringYearly" />
          </MappingFragment></EntityTypeMapping></EntitySetMapping>
          <EntitySetMapping Name="Reservatiestatussen"><EntityTypeMapping TypeName="Model.Reservatiestatus"><MappingFragment StoreEntitySet="reservatiestatussen">
            <ScalarProperty Name="statusId" ColumnName="statusId" />
            <ScalarProperty Name="statusnaam" ColumnName="statusnaam" />
          </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/2008/10/edmx">
    <Connection>
      <DesignerInfoPropertySet>
        <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
      </DesignerInfoPropertySet>
    </Connection>
    <Options>
      <DesignerInfoPropertySet>
        <DesignerProperty Name="ValidateOnBuild" Value="true" />
        <DesignerProperty Name="EnablePluralization" Value="False" />
        <DesignerProperty Name="IncludeForeignKeysInModel" Value="False" />
      </DesignerInfoPropertySet>
    </Options>
    <!-- Diagram content (shape and connector positions) -->
    <Diagrams>
      <Diagram Name="xxx">
        <EntityTypeShape EntityType="Model.Arrangement" Width="1.5" PointX="0.75" PointY="0.75" Height="2.3648893229166665" IsExpanded="true" />
        <EntityTypeShape EntityType="Model.Complex" Width="1.5" PointX="2.75" PointY="0.75" Height="1.7879850260416674" IsExpanded="true" />
        <EntityTypeShape EntityType="Model.Klant" Width="1.5" PointX="2.75" PointY="3.75" Height="1.787985026041667" IsExpanded="true" />
        <EntityTypeShape EntityType="Model.Reservatie" Width="1.5" PointX="4.75" PointY="0.75" Height="3.1340950520833335" IsExpanded="true" />
        <EntityTypeShape EntityType="Model.Reservatiestatus" Width="1.5" PointX="4.75" PointY="4.75" Height="1.4033821614583317" IsExpanded="true" />
      </Diagram>
    </Diagrams>
  </Designer>
</edmx:Edmx>

C-S映射内容下的所有内容都标记为错误。

我得到了“作为此MSL的一部分指定的EntitySet'X'在MetadataWorkspace中不存在。”对于我所有的桌子。

我很无能......

2 个答案:

答案 0 :(得分:2)

忘记添加MySql.Data.Entity dll的引用...

答案 1 :(得分:1)

您最好检查&lt; edmx:ConceptualModels&gt; &lt; Schema Namespace =&#34; ?????&#34; .......&gt;,在.EDMX文件中使用的Complex类型。

它应匹配&lt; ComplexTypeMapping TypeName =&#34; ?????.ComplexTypeName&#34; ....&gt;

它解决了我的问题......