c# - How to make DateTime field nullable in Local SQL db -


i'm working on asp.net mvc 4 project , i'm facing problem caused local data base. have few tables in there, in 1 of them have "datetime" type field. want field not required, have set "allow nulls" option in table's designer view "true". added data in table, in fact didn't enter values in "datetime" field.

when run app , try open view data table should appear error: "the 'datefrom' property on 'person' not set 'null' value. must set property non-null value of type 'datetime'"

could me issue?

ps: i'm using visualstudio 2012 ultimate , programming in c#

i created db code-first method:

here class of person:

using system; using system.collections.generic; using system.linq; using system.web; using system.componentmodel.dataannotations;  namespace personuregistrs.models      {         public class persona         {             [key]             [required]             public int personaid { get; set; }              public fiziskapersona fiziskapersona { get; set; }              public juridiskapersona juridiskapersona { get; set; }              [displayformat(nulldisplaytext="-")]             public string identifikacijasnumurs { get; set; }              public bool irprezidents { get; set; }              public double ien_likme { get; set; }              [displayformat(nulldisplaytext="-")]             public datetime ienspekano { get; set; }              [displayformat(nulldisplaytext = "-")]             public datetime ienspekalidz { get; set; }              public bool irmaksatnespejiga { get; set; }              public adrese adrese { get; set; }              public bool sanemtapkartparakstu { get; set; }              [required]             public ierakstastatuss ierakstastatuss { get; set; }              public list<strukturvieniba> personasstrukturvienibas { get; set; }         }     } 

and here designer view of table: enter image description here

enter image description here

it's not database problem. in person class, change datefrom property datetime datetime?. make nullable.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -