title: Entity Framework C# convert int to bool
body: <p>I'm attempting to re-write a VB.NET WebForms application in C# MVC. I'm having an issue with one of the properties when using Entity Framework to instantiate a class.</p>
  
  <p>I have a column in my database "VATInclusive", which is of type 'int'. The original application implicitly converted a "1" or "0" to "true" or "false", but when trying to do this in my application, I get the following error:</p>
  
  <blockquote>
    <p>The 'VATInclusive' property on 'Shop' could not be set to a
    'System.Int32' value. You must set this property to a non-null value
    of type 'System.Boolean'.</p>
  </blockquote>
  
  <p>I can't simply change the type in the database as other applications make use of the table. I've tried using the following code to convert the value, but it seems to only return false, regardless of whether the database has a "0" or a "1"... Can anybody suggest a solution to this?</p>
  
  <pre><code>    [Column("VATInclusive")]
      private int _VATInclusive { get; set; }
  
      [NotMapped]
      public bool VATInclusive
      {
          get
          {
              if (_VATInclusive == 0)
              {
                  return false;
              }
              else
              {
                  return true;
              }
          }
          set 
          {
              if(_VATInclusive == 0)
              {
                  this.VATInclusive = false;
              }
              else 
              {
                  this.VATInclusive = true;
              }
          }
      } 
  </code></pre>