public void Validate(SqlServerValidationToolkitContext ctxSqlServer)
 {
     foreach (var source in Sources
              //include the errorType to get to the code of the wrong-values
              .Include(
                  s => s.Columns
                  .Select(c => c.ValidationRules
                          .Select(r => r.Validation_WrongValue
                                  .Select(wv => wv.Errortype)
                                  )
                          )
                  )
              )
     {
         source.Validate(ctxSqlServer.Database.Connection, this);
     }
     SaveChanges();
     this.Database.ExecuteSqlCommand("DELETE FROM Validation_WrongValue WHERE Is_Corrected=1");
 }
        public static SqlServerValidationToolkitContext Create()
        {
            SqlServerValidationToolkitContext ctx;

            if (Settings.Default.StoreMetadataInSqlServer)
            {
                ctx = SqlServerValidationToolkitContext.Create(Settings.Default.MetadataDatabaseConnectionString);
            }
            else
            {
                string databaseFileName = "SqlServerValidationToolkit.Model.Context.SqlServerValidationToolkitContext.sdf";
                string sqlServerCompactConnectionString = string.Format("Data Source={0}", databaseFileName);

                ctx = new SqlServerValidationToolkitContext(sqlServerCompactConnectionString);
                if (!File.Exists(databaseFileName))
                {
                    ctx.Database.CreateIfNotExists();
                }
            }

            DatabaseInitializer.AddErrorTypes(ctx);

            return(ctx);
        }