实体框架未生成表或过程的类 [英] Entity Framework Not Generating Classes for Tables or Procedures
问题描述
我正在使用Entity Framework生成C#中的类和函数,我需要与SQL Server进行交互。
作为参考,这是我的一张桌子:
在
GO上设置ANSI_NULLS
在
GO $上设置QUOTED_IDENTIFIER b
$ b创建表[dbo]。[区域](
[ID] [bigint]身份(1,1)主键,
[名称] [nvarchar](100)NOT NULL
)
GO
运行实体数据模型向导后(使用 EF Designer from database'),我的项目有edmx文件和一些新的.cs文件,但似乎并没有生成它需要的一切。
在我的DatabaseEntities中例如,我有:
公共虚拟DbSet< Area>区域{get;组; }
但是,区域类型(以及其他三种缺失类型)没有定义。我也缺少存储过程的功能。
我尝试删除新文件并重新运行模型向导,但是得到相同的结果。 / p>
还有其他人遇到吗?
旁注:
在最近的几次尝试中,我注意到向导运行时也出现了错误:未在项目上安装Entity Framework程序包。但是,当我单击它时,它仍会生成edmx和model.context。
我在Entity Framework 6.0.0和6.1版本中都遇到了相同的问题.2。
重新安装框架对问题没有影响。
更新:
卸载nuget并重新安装最新版本,使我可以通过nuget安装EntityFramework,而不会出现错误。但是,现在添加新项对话框中缺少ADO.NET数据模型。
其中涉及多个步骤我做到了,我必须感谢在这个问题下方发表评论的人们。
1)我卸载了nuget软件包管理器,并重新安装了最新版本(显然我的是不新鲜)。
2)我不确定这样做是否有帮助,但我也重新安装了Entity Framework Tools通过Microsoft网站访问Visual Studio。我仍然不确定是否同时需要两者。
3)添加新项对话框中似乎缺少ADO.NET实体数据模型模板。选择添加->组件而不是添加->新项目后,它神秘地出现在两个列表中。
完成后,我能够运行EF Designer,并且一切生成的都没有问题。
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.
There were several steps involved in what I did, and I have to give some credit to the people who commented below the question.
1) I uninstalled nuget package manager and reinstalled the latest version (apparently mine was not fresh). This allowed me to install EntityFramework via nugget with no errors or rollback messages.
2) I'm not sure if this helped or not, but I also reinstalled Entity Framework Tools for Visual Studio via Microsoft's website. I'm still not sure if it's necessary to have both.
3) The ADO.NET Entity Data Model template appeared to be missing from the Add New Item dialogue. After selecting "Add -> Component" instead of "Add -> New Item", it then mystically appeared under both lists.
Once that was done, I was able to run EF Designer and everything generated with no problem.
这篇关于实体框架未生成表或过程的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!