我已经看到了几种可能的解决方案,但没有一个对我有用。
将 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)一篇帖子说使用系统。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>