I have an existing Database I am trying to use
Entity Framework Code First From Database to generate C# entities for. To do this I am doing
Add -> New Item -> ADO.NET Entity Data Model -> Code First from database inside Visual Studio 2015. When I go though the
Entity Data Model Wizard I see that every table is selected but when the import finishes entities for some of the tables where not created. I have tried this twice and double checked that the table with no entities are indeed selected for import. No errors are thrown during the import so I am not sure why some of the tables are missing there entitles. What might be going wrong and how do I get an entities for every single selected table?
SQL Create Table Code for one of the missing tables:
CREATE TABLE [dbo].[ProgramControl] ( [CodeName] VARCHAR (80) NULL, [CodeValue1] VARCHAR (50) NULL, [CodeValue2] VARCHAR (50) NULL, [CodeValue3] VARCHAR (50) NULL, [CodeValue4] VARCHAR (50) NULL, [Description] TEXT NULL );
EF code-first requires the use of a primary key on every entity, so the tool is not able to map these tables.
It looks like you might be able to work around this with some trickery, but adding a PK to every table is almost certainly the best approach.
If Table does not have at least one parameter not null ADO.NET will not generate the class. I don't know if it is a bug, just happened to me. It is not necessary to have a primary key but a not null.