I catch
System.Data.Entity.Infrastructure.DbUpdateException
HResult=0x80131501
Message=An error occurred while updating the entries. See the inner exception for details.
Source=EntityFramework
StackTrace:
at System.Data.Entity.Internal.InternalContext.SaveChanges()
at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
at System.Data.Entity.DbContext.SaveChanges()
at accwf.EmployeeAddForm.SaveItem() in D:\github\accwf\accwf\ListData\EmployeeAddForm.cs:line 75
at accwf.EmployeeAddForm.simpleButtonSave_Click(Object sender, EventArgs e) in D:\github\accwf\accwf\ListData\EmployeeAddForm.cs:line 34
at System.Windows.Forms.Control.OnClick(EventArgs e)
at DevExpress.XtraEditors.BaseButton.OnClick(EventArgs e)
at DevExpress.XtraEditors.BaseButton.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at DevExpress.Utils.Controls.ControlBase.BaseWndProc(Message& m)
at DevExpress.Utils.Controls.ControlBase.WndProc(Message& m)
at DevExpress.XtraEditors.BaseControl.WndProc(Message& msg)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at accwf.Program.Main() in D:\github\accwf\accwf\Program.cs:line 45
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
UpdateException: An error occurred while updating the entries. See the inner exception for details.
Inner Exception 2:
SqlException: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
The statement has been terminated.
object
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace accwf
{
using System;
using System.Collections.Generic;
public partial class AccountObject
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public AccountObject()
{
this.AccountObject1 = new HashSet<AccountObject>();
this.AccountObjectBankAccounts = new HashSet<AccountObjectBankAccount>();
this.AccountObjectShippingAddresses = new HashSet<AccountObjectShippingAddress>();
this.Contracts = new HashSet<Contract>();
}
public int ID { get; set; }
public string AccountObjectCode { get; set; }
public string AccountObjectName { get; set; }
public Nullable<int> Gender { get; set; }
public Nullable<System.DateTime> BirthDate { get; set; }
public string BirthPlace { get; set; }
public Nullable<decimal> AgreementSalary { get; set; }
public Nullable<decimal> SalaryCoefficient { get; set; }
public Nullable<int> NumberOfDependent { get; set; }
public Nullable<decimal> InsuranceSalary { get; set; }
public string BankAccount { get; set; }
public string BankName { get; set; }
public string Address { get; set; }
public string AccountObjectGroupList { get; set; }
public string AccountObjectGroupListCode { get; set; }
public string CompanyTaxCode { get; set; }
public string Tel { get; set; }
public string Mobile { get; set; }
public string Fax { get; set; }
public string EmailAddress { get; set; }
public string Website { get; set; }
public Nullable<int> PaymentTermID { get; set; }
public Nullable<decimal> MaxDebtAmount { get; set; }
public Nullable<int> DueTime { get; set; }
public string IdentificationNumber { get; set; }
public Nullable<System.DateTime> IssueDate { get; set; }
public string IssueBy { get; set; }
public string Country { get; set; }
public string ProvinceOrCity { get; set; }
public string District { get; set; }
public string WardOrCommune { get; set; }
public string Prefix { get; set; }
public string ContactName { get; set; }
public string ContactTitle { get; set; }
public string ContactMobile { get; set; }
public string OtherContactMobile { get; set; }
public string ContactFixedTel { get; set; }
public string ContactEmail { get; set; }
public string ContactAddress { get; set; }
public bool IsVendor { get; set; }
public bool IsCustomer { get; set; }
public bool IsEmployee { get; set; }
public bool AccountObjectType { get; set; }
public bool ActiveStatus { get; set; }
public Nullable<int> OrganizationUnitID { get; set; }
public Nullable<int> BranchID { get; set; }
public System.DateTime CreatedDate { get; set; }
public string CreatedBy { get; set; }
public Nullable<System.DateTime> ModifiedDate { get; set; }
public string ModifiedBy { get; set; }
public Nullable<decimal> ReceiptableDebtAmount { get; set; }
public string ShippingAddress { get; set; }
public string AccountObjectGroupListName { get; set; }
public Nullable<int> EmployeeID { get; set; }
public string Description { get; set; }
public string BankBranchName { get; set; }
public string BankProvinceOrCity { get; set; }
public string LegalRepresentative { get; set; }
public string EInvoiceContactName { get; set; }
public string EInvoiceContactEmail { get; set; }
public string EInvoiceContactAddress { get; set; }
public string EInvoiceContactMobile { get; set; }
public Nullable<int> EmployeeType { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<AccountObject> AccountObject1 { get; set; }
public virtual AccountObject AccountObject2 { get; set; }
public virtual OrganizationUnit OrganizationUnit { get; set; }
public virtual OrganizationUnit OrganizationUnit1 { get; set; }
public virtual PaymentTerm PaymentTerm { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<AccountObjectBankAccount> AccountObjectBankAccounts { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<AccountObjectShippingAddress> AccountObjectShippingAddresses { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Contract> Contracts { get; set; }
}
}
How to fix it?