Description:
The following MySQL Products were freshly installed on Windows Server 2012 DB machine:
mysql-installer-community-5.7.9.1
The following MySQL products were freshly installed on Windows 7
Visual Studio 2013 with Update 5
mysql-connector-net-6.9.8.msi
mysql-connector-net-6.8.7.msi (Also Trialled without success)
mysql-for-visualstudio-1.2.5.msi
In Visual studio when attempting to load ADO.Net entity framework Data model from an existing database the following error is encountered.
Unexpected exception occurred when generating the model. See output window for more details. Exception Message: 'StrongTypingException: The value for column 'IsPrimaryKey' in table 'TableDetails' is DBNull.'.
The Error recorded in the Output window in Visual Studio.
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`1 columns, IList`1 errors, List`1& keyColumns, List`1& excludedColumns, List`1& invalidKeyTypeColumns)
at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.CreateEntityType(IList`1 columns, Boolean& needsDefiningQuery)
at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.CreateEntitySets(IEnumerable`1 tableDetailsRows, EntityRegister entityRegister, IList`1 entitySetsForReadOnlyEntityTypes, DbObjectType objectType)
at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.StoreModelBuilder.CreateEntitySets(IEnumerable`1 tableDetailsRowsForTables, IEnumerable`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`1 errors)
at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModels(String storeModelNamespace, ModelBuilderSettings settings, List`1 errors)
at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModel(ModelBuilderSettings settings, IVsUtils vsUtils, ModelBuilderEngineHostContext hostContext)'.
Loading metadata from the database took 00:00:00.4447030.
Generating the model took 00:05:24.4807287.
How to repeat:
Create a new visual Studio Project.
Add NuGet Package MySQL.Data Version 6.9.8
Add NuGet Package MySql.Data.Entity 6.9.8
Add NuGet Package MySQL.Data.Entities 6.9.8
In Visual Studio, Right click on the active project-> Add -> New item
Select ADO.NET Entity Data Model
Select "EF Designer from Database"
Add MySQL Connection Details
In The Entity Data Model Wizard Select any table to import.
Pluralize or Singularize generated object names is checked.
Include Foreign key columns in the model unchecked
Import selected stored procedures and functions into the entity model unchecked.
Click Finish