protected void ButtonSave_Click(object sender, EventArgs e) {
using (IntranETEntities context = new IntranETEntities())
{
CUSTOMER customer = context.CUSTOMERs.FirstOrDefault<CUSTOMER>(p => p.CODE == TxtName.Text);
CUSTOMER_EXTENSION customerextension = null;
IE_CUSTOMER_INFO customerInfo = null;
ACADEMY academy = new ACADEMY();
JOB job = new JOB();
if (customer == null)
{
customer = new CUSTOMER();
context.AddToCUSTOMERs(customer);
customerextension = new CUSTOMER_EXTENSION();
customer.CUSTOMER_EXTENSION.Add(customerextension);
customerInfo = new IE_CUSTOMER_INFO();
customer.IE_CUSTOMER_INFO.Add(customerInfo);
}
else
{
customer.CUSTOMER_EXTENSION.Load();
customer.IE_CUSTOMER_INFO.Load();
customerextension = customer.CUSTOMER_EXTENSION.FirstOrDefault<CUSTOMER_EXTENSION>();
customerInfo = customer.IE_CUSTOMERINFO.First<IE_CUSTOMER_INFO>();
if (customerextension == null)
{
customerextension = new CUSTOMER_EXTENSION();
customer.CUSTOMER_EXTENSION.Add(customerextension);
}
else
customerextension.UPDATESEQ++;
if (customerInfo == null)
{
customer;Info = new IE_CUSTOMER_INFO();
customer.IE_CUSTOMER_INFO.Add(customerInfo);
}
....
customerextension.CREATE_DATE = DateTime.Now;
....
context.SaveChanges();//Error is occuring here.
} }
我正在使用更新的 EntityFramework。当我调试此代码时,我收到一条错误消息,提示 “将 datetime2 数据类型转换为 smalldatetime 数据类型导致值超出范围。\r\n语句已终止。” 我无权更改数据库中列的类型。并且该列不为空。我该如何解决?
感谢您的回复!!!