使用sql日期数据类型和EF4 [英] Using sql date data type and EF4

查看:172
本文介绍了使用sql日期数据类型和EF4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,一个sql日期数据类型。当我查看EDM标记时,存储元素反映了这一点。概念实体的数据类型为DateTime(似乎不是Date数据类型)。当我调用保存更改并且有一个与要保留的实体相关联的DateTime实例时,我会收到以下错误:



将datetime2数据类型转换为datetime数据类型导致超出范围的值。
该语句已被终止。



如何在我的架构中使用日期数据类型并具有EF行为?谢谢!

解决方案

听起来像您的SQL日期列不可为空,但您尚未在您的实体上初始化日期保存?


I have a table w/ a sql date data type. When I look at the EDM markup, the storage element reflects this. The conceptual entity has a data type of DateTime (there doesn't appear to be a Date data type). When I call save changes and have a DateTime instance associated w/ the entity I want to persist, I get the following error:

The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. The statement has been terminated.

How can I use the date data type in my schema and have EF behave? Thanks!

解决方案

Sounds like your SQL date column is non-nullable, but you haven't initialized the date on your entity before saving?

这篇关于使用sql日期数据类型和EF4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆