Ado.Net Entity produces "namespace cannot be found"

Posted by Dave on Stack Overflow See other posts from Stack Overflow or by Dave
Published on 2012-11-21T16:45:11Z Indexed on 2012/11/21 16:59 UTC
Read the original article Hit count: 267

Filed under:
|
|

I've seen several possible solutions to this, but none have worked for me.

After adding a ADO.NET Entity Data Model to my .Net Forms C# web project, I am unable to use it.

Perhaps I made a mistake adding it? The name of the file added is QcFormData.edmx.

In my code, perhaps I'm instantiating it incorrectly? I tried adding the line:

QcFormDataContainer db = new QcFormDataContainer();

It appears in Intellisense, but when compiling I get the error :

Error   13  The type or namespace name 'QcFormDataContainer' could not be found (are you missing a using directive or an assembly reference?)

I've followed the suggestions that I found online that did not help:

1) made sure there is "using System.Data.Entity"

2) made sure the dll exists.

3) made sure the reference exists.

4) one post said use using System.Web.Data.Entity; but I do not see that available.

What am I missing?

QcFormData.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="MyCocoModel.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="MyCocoModelStoreContainer">
          <EntitySet Name="QcFieldValues" EntityType="MyCocoModel.Store.QcFieldValues" store:Type="Tables" Schema="dbo" />
        </EntityContainer>
        <EntityType Name="QcFieldValues">
          <Key>
            <PropertyRef Name="ID" />
          </Key>
          <Property Name="ID" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="FieldID" Type="nvarchar" MaxLength="100" />
          <Property Name="FieldValue" Type="nvarchar" MaxLength="100" />
          <Property Name="DateTimeAdded" Type="datetime" />
          <Property Name="OrderReserveNumber" Type="nvarchar" MaxLength="50" />
        </EntityType>
      </Schema>
    </edmx:StorageModels>
    <!-- CSDL content -->
    <edmx:ConceptualModels>
      <Schema Namespace="MyCocoModel" 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="MyCocoEntities" p1:LazyLoadingEnabled="true">
          <EntitySet Name="QcFieldValues" EntityType="MyCocoModel.QcFieldValue" />
        </EntityContainer>
        <EntityType Name="QcFieldValue">
          <Key>
            <PropertyRef Name="ID" />
          </Key>
          <Property Name="ID" Type="Int32" Nullable="false" p1:StoreGeneratedPattern="Identity" />
          <Property Name="FieldID" Type="String" MaxLength="100" Unicode="true" FixedLength="false" />
          <Property Name="FieldValue" Type="String" MaxLength="100" Unicode="true" FixedLength="false" />
          <Property Name="DateTimeAdded" Type="DateTime" Precision="3" />
          <Property Name="OrderReserveNumber" Type="String" MaxLength="50" 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="MyCocoModelStoreContainer" CdmEntityContainer="MyCocoEntities">
          <EntitySetMapping Name="QcFieldValues">
            <EntityTypeMapping TypeName="MyCocoModel.QcFieldValue">
              <MappingFragment StoreEntitySet="QcFieldValues">
                <ScalarProperty Name="ID" ColumnName="ID" />
                <ScalarProperty Name="FieldID" ColumnName="FieldID" />
                <ScalarProperty Name="FieldValue" ColumnName="FieldValue" />
                <ScalarProperty Name="DateTimeAdded" ColumnName="DateTimeAdded" />
                <ScalarProperty Name="OrderReserveNumber" ColumnName="OrderReserveNumber" />
              </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>

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET