public void ValidationDisabled() { using (var db = new MyContext()) { Database.SetInitializer(new DropCreateDatabaseAlways<MyContext>()); Article articleLengthTest = new Article { Title = "My Title", Description = "Short text" }; db.Articles.Add(articleLengthTest); db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); // uložení projde, protože MinLength() není db constraint } }
public void ValidationFailed() { using (var db = new MyContext()) { Database.SetInitializer(new DropCreateDatabaseAlways<MyContext>()); Article articleLengthTest = new Article { Title = "My Title", Description = "Short text" }; db.Articles.Add(articleLengthTest); db.SaveChanges(); } }