0
我已經看到了幾種可能的解決方案,但沒有人爲我工作。Ado.Net Entity產生「無法找到命名空間」
將ADO.NET實體數據模型添加到我的.Net Forms C#web項目後,我無法使用它。
也許我在添加它時犯了一個錯誤?添加的文件的名稱是QcFormData.edmx。
我正在實例化這不正確?我嘗試添加一行:
QcFormData db = new QcFormData();
Error 13 The type or namespace name 'QcFormData' could not be found (are you missing a using directive or an assembly reference?)
我跟着,我在網上找到的建議,並沒有幫助:
1)確信有「使用System.Data.Entity的」
2)確保dll存在。
3)確保參考存在。
4)一篇文章說使用System。 Web .Data.Entity;但我沒有看到可用的。
我錯過了什麼?
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="MyCoModel.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="MyCoModelStoreContainer">
<EntitySet Name="QcFieldValues" EntityType="MyCoModel.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="MyCoModel" 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="MyCoEntities" p1:LazyLoadingEnabled="true">
<EntitySet Name="QcFieldValues" EntityType="MyCoModel.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="MyCoModelStoreContainer" CdmEntityContainer="MyCoEntities">
<EntitySetMapping Name="QcFieldValues">
<EntityTypeMapping TypeName="MyCoModel.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>
它在一個文件夾中嗎? –
不,它位於項目的根目錄,以及我從中調用的aspx文件和aspx.cs文件。 – Dave
QcFormDataContainer是如何定義的? –