在使用实体框架保存实体时,它会抛出“字符串或二进制数据将被截断”。例外。在使用sql profiler检查后,我发现问题在这句话中:
@86=''2011-10-12 00:00:00:000''
原因是第二个“'”。如果我摆脱了第二个引用,sql语句执行没有任何问题。
这里有一些emdx ......
<edmx:StorageModels>
<Schema Namespace="Model1.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">
<EntityType Name="NI_0690">
...
<Property Name="StartDate" Type="datetime" />
...
</EntityType>
</Schema></edmx:StorageModels>
<edmx:ConceptualModels>
<Schema xmlns="http://schemas.microsoft.com/ado/2006/04/edm" Namespace="Model1" Alias="Self">
<EntityType Name="NI_0690">
...
<Property Name="StartDate" Type="DateTime" Nullable="true" />
...
</EntityType>
</Schema>
</edmx:ConceptualModels>
<edmx:Mappings>
<Mapping xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS" Space="C-S">
<Alias Key="Model" Value="Model1" />
<Alias Key="Target" Value="Model1.Store" />
....
<EntitySetMapping Name="NI_0690">
<EntityTypeMapping TypeName="IsTypeOf(Model1.NI_0690)">
<MappingFragment StoreEntitySet="NI_0690">
....
<ScalarProperty Name="StartDate" ColumnName="StartDate" />
....
</MappingFragment>
</EntityTypeMapping>
</Mapping>
</edmx:Mappings>
关于如何解决这个问题的想法?