Entity Framework Not Generating Classes for Tables or Procedures

Nightmare Games picture Nightmare Games · Feb 17, 2015 · Viewed 23.6k times · Source

I'm using the Entity Framework to generate the classes and functions in C# I need to interact with the SQL server.

For reference, here's one of my tables:

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Area](
    [ID] [bigint] identity (1, 1) primary key,
    [Name] [nvarchar](100) NOT NULL
    )
GO

After running the Entity Data Model Wizard (using 'EF Designer from database'), my project has the edmx file and a few new .cs files, but it seems like it's not generating everything it needs.

In my DatabaseEntities class, for example, I've got:

    public virtual DbSet<Area> Areas { get; set; }

However, there's no definition for the type 'Area' (along with three other missing types). I'm also missing the functions for stored procedures.

I've tried deleting the new files and re-running the Model Wizard, but I get the same result.

Has anyone else run into this?

SIDENOTES:

I've noticed during the last few attempts that I'm also getting an error when the wizard runs: "The Entity Framework package not installed on project". However, it's still generating the edmx and the model.context when I click past it.

I've had the same problem with both Entity Framework versions 6.0.0 and 6.1.2.

Reinstalling the framework had no effect on the problem(s).

UPDATE:

Uninstalling nuget and reinstalling the latest version allowed me to install EntityFramework via nuget without error. However, now the ADO.NET data model is missing from the Add New Item dialogue.

Answer

Divakar Mayakrishnan picture Divakar Mayakrishnan · Mar 20, 2019

Make sure the table has a key column. It will not generate the view if there is no key column in a table.