我收到此错误:
System.Data.Entity.Validation.DbEntityValidationException:一个或多个实体的验证失败。有关详细信息,请参阅“EntityValidationErrors”属性。
在视觉工作室。这里有几个关于它的帖子,但是它们似乎都在应用程序流程中的某个地方运行“种子”方法。
在我的情况下,我试图在迁移配置中播种数据库。如果这是不明智的请告诉我。
现在有办法在Update-Database
运行时捕获异常或以任何方式中断。如何查看错误消息的详细信息?
protected override void Seed(AppContext context)
{
User[] Users = new User[]
{
new User()
{
Id = new Guid().ToString(),
FirstMidName = "Arianne",
LastName = "Brower",
BirthDate = DateTime.Now,
UserType = UserType.Member,
Gender = Gender.Female,
ExerPoints = 500,
Contact = new Contact()
{
Address = "#2 HomeLand Rd, Central Town",
PhoneNumber = "1-868-555-0912",
}
},
new User()
{
Id = new Guid().ToString(),
FirstMidName = "Melaino",
LastName = "Cruaino",
BirthDate = DateTime.Now,
UserType = UserType.Instructor,
Gender = Gender.Male,
ExerPoints = 1520,
Contact = new Contact()
{
Id = new Guid().ToString(),
Address = "#2 HomeLand Rd, Central Town",
PhoneNumber = "1-868-555-0912",
}
},
new User()
{
Id = new Guid().ToString(),
FirstMidName = "Darion",
LastName = "Carpenter",
BirthDate = DateTime.Now,
UserType = UserType.Member,
Gender = Gender.Male,
ExerPoints = 2960,
Contact = new Contact()
{
Id = new Guid().ToString(),
Address = "#2 HomeLand Rd, Central Town",
PhoneNumber = "1-868-555-0912",
}
},
new User()
{
Id = new Guid().ToString(),
FirstMidName = "Alexa",
LastName = "Bringer",
BirthDate = DateTime.Now,
UserType = UserType.Member,
Gender = Gender.Female,
ExerPoints = 3900,
Contact = new Contact()
{
Id = new Guid().ToString(),
Address = "#2 HomeLand Rd, Central Town",
PhoneNumber = "1-868-555-0912",
}
},
new User()
{
Id = new Guid().ToString(),
FirstMidName = "Alexa",
LastName = "Bringer",
BirthDate = DateTime.Now,
UserType = UserType.Organizer,
Gender = Gender.Female,
ExerPoints = 12000,
Contact = new Contact()
{
Id = new Guid().ToString(),
Address = "#2 HomeLand Rd, Central Town",
PhoneNumber = "1-868-555-0912",
}
}
};
context.Users.AddOrUpdate(Users);
Club[] Clubs = new Club[]
{
new Club()
{
Id = new Guid().ToString(),
Name = "Road Runners",
ContactInfo = new Contact() {
Id = new Guid().ToString(),
Address = "Lakanda Rd, POS",
PhoneNumber = "1-868-555-0011",
Website = "www.roadrunnerstt.tt"
},
PointsDistributed = 15950,
PointsEarned = 25500
},
new Club()
{
Id = new Guid().ToString(),
Name = "Weightornators",
ContactInfo = new Contact() {
Id = new Guid().ToString(),
Address = "Lakanda Rd, POS",
PhoneNumber = "1-868-555-0011",
Website = "www.weightornators.tt"
},
PointsDistributed = 250000,
PointsEarned = 325000
},
};
context.Clubs.AddOrUpdate(
Clubs
);
}
}