外鍵我有兩個表:operation
和。兩列在實體框架
operation
表具有複合主鍵operation_id: bigint
和date_data: nvarchar(10)
。也有這些列。基於這兩列的表格之間存在關係。添加ADO.NET實體數據模式後,出現兩個錯誤:
錯誤13101:參照約束的從屬角色中的所有屬性的類型必須與主體角色中的相應屬性類型相同。該類型的特性「operation_date_data」對實體「operation_category_element_relation」不引用約束「FK_operation_category_element_relation_operation」相匹配的屬性的類型「operation_id」對實體「操作」。
和
錯誤13101:類型在參照約束的從屬角色所有屬性必須是一樣的,在主體作用相應的屬性類型。該屬性類型的實體「operation_category_element_relation」 operation_id「在引用約束「FK_operation_category_element_relation_operation」不匹配的特性「date_data」類型的實體「操作」。
你能解釋一下問題是什麼以及如何擺脫它?
自動生成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 xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl" Namespace="TEMPDataModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005">
<EntityContainer Name="TEMPDataModelTargetContainer"></EntityContainer>
</Schema>
</edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema xmlns="http://schemas.microsoft.com/ado/2009/11/edm" xmlns:cg="http://schemas.microsoft.com/ado/2006/04/codegeneration" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" Namespace="TEMPDataModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" annotation:UseStrongSpatialTypes="false">
<EntityContainer Name="TEMPDataModelContainer" annotation:LazyLoadingEnabled="true"></EntityContainer>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs" Space="C-S">
<Alias Key="Model" Value="TEMPDataModel" />
<Alias Key="Target" Value="TEMPDataModel.Store" />
<EntityContainerMapping CdmEntityContainer="TEMPDataModelContainer" StorageEntityContainer="TEMPDataModelTargetContainer"></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="UseLegacyProvider" Value="false" />
<DesignerProperty Name="CodeGenerationStrategy" Value="None" />
</DesignerInfoPropertySet>
</Options>
<!-- Diagram content (shape and connector positions) -->
<Diagrams></Diagrams>
</Designer>
</edmx:Edmx>
哪些數據類型operation_id'和''operation_category_element_relation'的date_data''?他們需要是一樣的。 –
他們都是一樣的 - 我沒有寫出來,但他們是相同的操作 – Marcin