I have a table called Tournaments which is created using the EF code first approach with the following attributes:
public int TournamentID { get; set; }
public String Name { get; set; }
public String DirectorSurname { get; set; }
public String DirectorFirstName { get; set; }
public String Logo { get; set; }
public String Timezone { get; set; }
public String Telephone { get; set; }
public String Fax { get; set; }
public String Email { get; set; }
public String Website { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public int IntervalTime { get; set; }
If I run this and check my SQL Server Management Studio then the StartDate and EndDate gets created but it is non-nullable despite me not adding the [Required] DataAnnotations. How can I fix this?
Try this:
C# nullable types gets converted to SQL nullable.