Entity Framework Not Generating Classes for Tables or Procedures

ado.net-entity-data-model c# entity-framework sql-server

Question

To create the classes and functions in C# I need to communicate with the SQL server, I use the Entity Framework.

Here's one of my tables for reference:

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

My project now has the edmx file and a few new.cs files after running the Entity Data Model Wizard (using "EF Designer from database"), but it doesn't seem to be generating all it needs.

For instance, in my DatabaseEntities class, I have:

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

However, the type "Area" lacks a definition (along with three other missing types). The functions for stored procedures are likewise missing for me.

I've attempted to remove the new files and restart the Model Wizard, but I still experience the same issue.

Has this happened to anyone else?

SIDENOTES:

The last few times I've tried, I've observed that I'm also getting the message "The Entity Framework package not installed on project" when the wizard launches. When I click past it, though, it continues to generate the model.context and the edmx.

Both Entity Framework versions 6.0.0 and 6.1.2 gave me the same issues.

The issue was unaffected by the framework being reinstalled (s).

UPDATE:

I was able to successfully install EntityFramework via nuget by uninstalling nuget and reinstalling the most recent version. However, the Add New Item window no longer includes the ADO.NET data model.

1
7
2/18/2015 11:45:43 PM

Accepted Answer

The things I performed required a number of stages, and I must offer some thanks to the people who left comments beneath the question.

1) I reinstalled the most recent version of Nuget Package Manager after uninstalling it originally (apparently mine was not fresh). This prevented any issues or rollback notifications throughout my installation of EntityFramework using Nugget.

2) I reinstalled Entity Framework Tools for Visual Studio from Microsoft's website, but I'm not sure if that did any good. I'm still unsure if having both is required.

3) The Add New Item dialogue box didn't seem to have the ADO.NET Entity Data Model template. It then magically appeared under both lists after choosing "Add -> Component" rather than "Add -> New Item."

Following completion of that, I was able to launch EF Designer and everything generated without any issues.

2
2/19/2015 12:19:10 AM

Popular Answer

A key column must be present in the table. If a table does not contain a key column, the view cannot be generated.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow