Framework entity does not create classes for tables or procedures

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

For reference, here is 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 starting the Entity Data Model Wizard (using "EF Designer from database"), my project has an edmx file and some new .cs files, but it seems that it does not generate everything that it needs.

In my DatabaseEntities class, for example, I have:

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

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

I tried to delete new files and re-run the Model Wizard, but I get the same result.

Anyone else come across this?

SIDENOTES:

I noticed that during the last few attempts I also get an error message when starting the wizard: "Entity Framework package is not installed in the project." However, it still generates edmx and model.context when I click on it.

I had the same issue with both versions 6.0.0 and 6.1.2 for Entity Framework.

Reinstalling the framework did not affect the problem.

UPDATE:

Removing nuget and reinstalling the latest version allowed me to install EntityFramework via nuget without errors. However, the ADO.NET data model is now missing from the Add New Item dialog box.

+6
source share
3 answers

There were several steps in what I did, and I have to give credit to the people who commented below the question.

1) I uninstalled the nuget package manager and reinstalled the latest version (apparently mine was not fresh). This allowed me to set the EntityFramework through the nugget without error or message rollback.

2) I'm not sure if this helped or not, but I also reinstalled the Entity Framework tools for Visual Studio through the Microsoft website. I'm still not sure you need to have both.

3) The ADO.NET entity data model template was missing in the Add New Item dialog box. After choosing “Add → Component” instead of “Add → New Item”, he then mystically appeared under both lists.

Once this was done, I was able to run EF Designer and all without problems.

+2
source

Make sure column names are not reserved words, such as data types or keywords; I had a problem today when trying to import a table with a column that someone simply called "DATE", which is obviously a data type, and it eclipses EF. When I created the view in SQL and smoothed a column with an unconditional name, the table imported just fine and generated all the necessary classes.

0
source

Personally, I would highly recommend using the Code-First approach, not the designer. The designer is just a problem !!!

First Interface Tutorial

Calling stored procedures from the first code

-3
source

Source: https://habr.com/ru/post/982637/


All Articles