title: MySQL - Entity : The value for column 'IsPrimaryKey' in table 'TableDetails' is DBNull
body: <p>I am using <strong>Visual Studio 2013</strong> with <strong>Entity Framework 5</strong> and M<strong>ySQL Server 5.7.9</strong>.</p>
  
  <p>When trying to create a Model from the database (<em>or 'Update Model From Database'</em>) the following message appears:</p>
  
  <blockquote>
    <p>'System.Data.StrongTypingException: The value for column
    'IsPrimaryKey' in table 'TableDetails' is DBNull . ---> System.InvalidCastException: Specified cast is not valid.</p>
  </blockquote>
  
  <p>I know that this question has been asked before, but i haven't find any solution.
  Also i don't have the option of downgrading to MySQL 5.6.</p>
  
  <p>The problem occurs even for a simple table.</p>
  
  <p>The sample table</p>
  
  <pre><code>CREATE TABLE new_table
  (
    id int(11) NOT NULL AUTO_INCREMENT,
    name varchar(45) NOT NULL,
    PRIMARY KEY (id)
  ) 
  ENGINE = InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p>If the table consists only from the Primary Key then the model is being created as it should.</p>
  
  <p><strong>EDIT:</strong>
  If i make both the fields PRIMARY Keys the model is being created without any errors.</p>
  
  <p>Does anyone have any idea about this?</p>
  
  <p>Kind Regards.</p>
  
  <p>The full error stack:</p>
  
  <blockquote>
    <p>Unable to generate the model because of the following exception:
    'System.Data.StrongTypingException: The value for column
    'IsPrimaryKey' in table 'TableDetails' is DBNull. --->
    System.InvalidCastException: Specified cast is not valid.    at
    Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.TableDetailsRow.get_IsPrimaryKey()
    --- End of inner exception stack trace ---    at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.SchemaDiscovery.TableDetailsRow.get_IsPrimaryKey()
    at
    Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.CreateProperties(IList<code>1
    columns, IList</code>1 errors, List<code>1&amp; keyColumns, List</code>1&amp; excludedColumns,
    List<code>1&amp; invalidKeyTypeColumns)    at
    Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.CreateEntityType(IList</code>1
    columns, Boolean&amp; needsDefiningQuery)    at
    Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.CreateEntitySets(IEnumerable<code>1
    tableDetailsRows, EntityRegister entityRegister, IList</code>1
    entitySetsForReadOnlyEntityTypes, DbObjectType objectType)    at
    Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.CreateEntitySets(IEnumerable<code>1
    tableDetailsRowsForTables, IEnumerable</code>1 tableDetailsRowsForViews,
    EntityRegister entityRegister)    at
    Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.Build(StoreSchemaDetails
    storeSchemaDetails)    at
    Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.CreateStoreModel()
    at
    Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.GenerateModel(List<code>1
    errors)    at
    Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModels(String
    storeModelNamespace, List</code>1 errors)    at
    Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModel(EdmxHelper
    edmxHelper)'. Loading metadata from the database took
    00:00:00.5856317.</p>
  </blockquote>