I get the following error when I'm trying to update-database
in the migration steps (open the Package Manager Console window and enter "update-database" command)
System.Data.Entity.Validation.DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
I add new field in the Movie
class
public class Movie
{
public int ID { get; set; }
[Required]
[DisplayName("Name")]
public string MovieName { get; set; }
[Required]
[DisplayName("Type")]
public string MovieType { get; set; }
[DisplayName("Year")]
public int MovieProductionYear { get; set; }
[Range(1, 5)]
[DisplayName("Priority")]
public int priority { get; set; }
[DisplayName("NoOfWatches")]
public int NumberOfWatches { get; set; }
[DisplayName("isWatched")]
public bool isWatched { get; set; }
[Range(1, 10)]
[DisplayName("IMDB")]
public int IMDBRating { get; set; }
[DisplayName("Available")]
public bool Availability { get; set; }
[StringLength(50)]
[DisplayName("Comments")]
public string Comments { get; set; }
[DisplayName("Actor")]
public string Actor { get; set; }
[DataType(DataType.Date)]
public DateTime ReleasedDate { get; set; }
}
and the add migration class for the new fields contains this up and down methods
public override void Up()
{
AddColumn("dbo.Movies", "NumberOfWatches", c => c.Int(nullable: false));
AddColumn("dbo.Movies", "ReleasedDate", c => c.DateTime(nullable: false));
}
public override void Down()
{
DropColumn("dbo.Movies", "ReleasedDate");
DropColumn("dbo.Movies", "NumberOfWatches");
}
When I remove the two fields and update the database the seed method runs successfully
Any suggestions?
Thank you.