Cannot insert the value NULL into column in ASP.NET MVC Entity Framework

I solved it by adding [DatabaseGenerated(DatabaseGeneratedOption.None)] like this:

public class Customers
    {   
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public long Sessionid { get; set; }
        public long? Pers { get; set; }
    }

You can configure SQL to auto-generate (and auto-increment) the primary key for the table upon inserts. Then just remove the [Key] in C# and you don't need to set the ID in the application manually, the db will generate it for you.