title: Entity Framework Code First - Cast smallint and integer to int32
body: <p>Im working on a small service tool for a database. My problem is that due the last update, some smallint-colums had to be be changed into integer. </p>
  
  <pre><code>public class TEST
  {
      public int ID { get; set; }
      //public Int16 ID { get; set; }
      public string TEST { get; set; }
  
  }
  </code></pre>
  
  <p>I changed the type from Int16 to int. Everything works fine, except that I can't use it with the old Version of the Database anymore. The Exception is something like "System.Int32 expected, found Typ System.Int16". </p>
  
  <p>Is there a way to cast all smallint and integer to int32? </p>
  
  <p>Any ideas? My Environment: EntityFramework 5.0.0 .NET 4.5 FirebirdClient 3.0.2.0</p>
  
  <p>I tried to force a cast in the modelbuilder:</p>
  
  <pre><code>        modelBuilder.Entity&lt;TEST&gt;()
          .Property(p =&gt; p.ID)
          .HasColumnType("smallint");
  </code></pre>
  
  <p>Exception: </p>
  
  <blockquote>
    <p>error 2019: Member Mapping specified is not valid. The type 'Edm.Int32[Nullable=False,DefaultValue=]' of member 'ID' in Typ 'ContextRepository.TEST' is not compatible with 'FirebirdClient.smallint[Nullable=False,DefaultValue=,StoreGeneratedPattern=Identity]' of member 'SCHLUESSEL' in type 'CodeFirstDatabaseSchema.BUNDLAND'</p>
  </blockquote>
  
  <p>Make the ID Int16 and then casting everything to smallint (HasColumnType("int")) works fine but would give me exceptions with numbers bigger than 31767(smallint max)...</p>