title: Entity - Schema Mapping and Namespaces
body: <p>Added a Database and an Entity Model to my DAL Project.</p>
  
  <h2>got an error :</h2>
  
  <p><strong>Error :</strong></p>
  
  <pre><code> +      base    {"Schema specified is not valid. Errors: \r\nMultiple types with the name 'TblRecord' exist in the EdmItemCollection in different namespaces.  Convention based mapping requires unique names without regard to namespace in the EdmItemCollection."}   System.Data.EntityException {System.Data.MetadataException}
  </code></pre>
  
  <hr>
  
  <p><strong>The Edmx File</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx"&gt;
    &lt;!-- EF Runtime content --&gt;
    &lt;edmx:Runtime&gt;
      &lt;!-- SSDL content --&gt;
      &lt;edmx:StorageModels&gt;
        &lt;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"&gt;
          &lt;EntityContainer Name="XzBusinessMatchesStoreContainer"&gt;
            &lt;EntitySet Name="Records" EntityType="Xz.Business.Matches.Store.Records" store:Type="Tables" /&gt;
          &lt;/EntityContainer&gt;
          &lt;EntityType Name="Records"&gt;
            &lt;Key&gt;
              &lt;PropertyRef Name="Record" /&gt;
            &lt;/Key&gt;
            &lt;Property Name="Record" Type="nvarchar" Nullable="false" MaxLength="100" /&gt;
            &lt;Property Name="Relations" Type="nvarchar" MaxLength="450" /&gt;
          &lt;/EntityType&gt;
        &lt;/Schema&gt;
      &lt;/edmx:StorageModels&gt;
      &lt;!-- CSDL content --&gt;
      &lt;edmx:ConceptualModels&gt;
        &lt;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"&gt;
          &lt;EntityContainer Name="RecordzEntities" p1:LazyLoadingEnabled="true"&gt;
            &lt;EntitySet Name="Records" EntityType="Xz.Business.Matches.TblRecord" /&gt;
          &lt;/EntityContainer&gt;
          &lt;EntityType Name="TblRecord"&gt;
            &lt;Key&gt;
              &lt;PropertyRef Name="Record" /&gt;
            &lt;/Key&gt;
            &lt;Property Name="Record" Type="String" Nullable="false" MaxLength="100" Unicode="true" FixedLength="false" /&gt;
            &lt;Property Name="Relations" Type="String" MaxLength="450" Unicode="true" FixedLength="false" /&gt;
          &lt;/EntityType&gt;
        &lt;/Schema&gt;
      &lt;/edmx:ConceptualModels&gt;
      &lt;!-- C-S mapping content --&gt;
      &lt;edmx:Mappings&gt;
        &lt;Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs"&gt;
          &lt;EntityContainerMapping StorageEntityContainer="XzBusinessMatchesStoreContainer" CdmEntityContainer="RecordzEntities"&gt;
            &lt;EntitySetMapping Name="Records"&gt;
              &lt;EntityTypeMapping TypeName="Xz.Business.Matches.TblRecord"&gt;
                &lt;MappingFragment StoreEntitySet="Records"&gt;
                  &lt;ScalarProperty Name="Record" ColumnName="Record" /&gt;
                  &lt;ScalarProperty Name="Relations" ColumnName="Relations" /&gt;
                &lt;/MappingFragment&gt;
              &lt;/EntityTypeMapping&gt;
            &lt;/EntitySetMapping&gt;
          &lt;/EntityContainerMapping&gt;
        &lt;/Mapping&gt;
      &lt;/edmx:Mappings&gt;
    &lt;/edmx:Runtime&gt;
    &lt;!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) --&gt;
    &lt;Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx"&gt;
      &lt;Connection&gt;
        &lt;DesignerInfoPropertySet&gt;
          &lt;DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" /&gt;
        &lt;/DesignerInfoPropertySet&gt;
      &lt;/Connection&gt;
      &lt;Options&gt;
        &lt;DesignerInfoPropertySet&gt;
          &lt;DesignerProperty Name="ValidateOnBuild" Value="true" /&gt;
          &lt;DesignerProperty Name="EnablePluralization" Value="True" /&gt;
          &lt;DesignerProperty Name="IncludeForeignKeysInModel" Value="True" /&gt;
          &lt;DesignerProperty Name="CodeGenerationStrategy" Value="None" /&gt;
        &lt;/DesignerInfoPropertySet&gt;
      &lt;/Options&gt;
      &lt;!-- Diagram content (shape and connector positions) --&gt;
      &lt;Diagrams&gt;&lt;/Diagrams&gt;
    &lt;/Designer&gt;
  &lt;/edmx:Edmx&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>Names &amp; Namespaces :</strong></p>
  
  <p>Project Name : Business.Matches
  Default Namespace : Xz.Business.Matches</p>
  
  <p>I added an Entity Model with this definitions :</p>
  
  <p>Model : RecordzModel</p>
  
  <p>Context : RecordzContext</p>
  
  <p>Model Namespace : Xz.Business.Matches</p>