title: Integer Validation in Entity Framework
body: <p>I am trying to use a DBContext to automatically validate my entities and display a message on screen. The get validation errors successfully detects all non-nullable properties of type string as they still have a value of null. My problem arises when I try to validate a property of type int. The value is already set to 0 by default and as it is a foreign key id I need this value to not be 0,but it does not get detected.</p>
  
  <pre><code>        //Create a database context over current ObjectContext          
          var databaseContext = new DbContext(this, true);
  
          //Get Validation Errors
          var errors = databaseContext.GetValidationErrors();
  
          //Display errors on screen
          if (errors.Any())
          {
              var errorList = new StringBuilder();
  
              foreach (var error in errors)
              {
                  foreach (var validationError in error.ValidationErrors)
                  {
                      errorList.AppendLine(validationError.ErrorMessage);
                  }
              }
  
              var vm = IoC.Get&lt;ModalConfirmationViewModel&gt;();
              vm.Message = errorList.ToString();
  
              var wm = IoC.Get&lt;WindowManager&gt;();
              wm.ShowDialog(vm);
  
              return false;
          }
  </code></pre>
  
  <p>Thoughts?</p>
  
  <p>Thanks
  Ben</p>