asp.net mvc - EF 4.1 Code First: "non-null value of type 'DateTime'" Issue -


After the initial dev and testing, I have now pointed to my MVC3 application in an existing database that includes live data.

However, I am related to this error type "DateTime" type field called Date1.
  'Date1' property on 'staff attachment' can not be set to 'empty' value. You have to set this property in non-null value of 'datetime' type.   

Is it telling me that all the rows in the date should be a date and should not be empty?

Can anyone give advice on solving this issue?

thanks paul

1 edit (posting model)

  public class staffing attorney {{key} public interactive {receive; Set; } Public int? {Receive Staff ID; Set; } Public int? TypeID {Receive; Set; } [Required] [DisplayName ("proof of ID")] public int? AttachmentTipID {Receive; Set; } [Required] [DisplayName ("ID Reference")] Public String Reference 1 {get; Set; } Public String Context 2 {get; Set; } Public string date type {get; Set; } [DisplayName ("expiration date")] Public Date Time Date 1; Set; } [Required] Public Date Time Date 2 {Receive; Set; } Public Date Time Date 3; Set; } Public Date Time Date 4 {Received; Set; } Public string attachment path {get; Set; } Public int? Valid userID {receive; Set; } Public Date Time Certified Date {Received; Set; } Public int? Created uisID {Received; Set; } Created public date time {receive; Set; } Public int? Edited User ID {Received; Set; } Edited public date time {get; Set; } Public TimeSpain Timestamp {get; Set; } Public string filename {get; Set; } Byte [] FileImage {get; Set; } Public Int Attachment Indicator {Receive; Set; }}    

Is it telling me that all the rows in the date Must have a date and not be empty? What do I do if I do not have to set a date on a specific line?

It seems that DB points to you that there are zero values ​​for Date1 .If you do not really want to set a date for all the rows , Make your the date 1 property worth:

  the public date time? Date1 {get} set;}   

Alternatively, you can only enter a default date for all those rows, which currently do not have DATA set via SQL.

Comments