I was creating a database table in Entity Framework Core 6.0. I was using code first approach in my project.
There was a string type property in TestModel
named Address
.
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TestProjectForCore6.Models
{
public class TestModel
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Address { get; set; }
}
}
When I add migration for this model, it creates a nullable false
column in migration builder:
In Entity Framework Core 5.0, we don't need to add explicitly define string property as nullable.