实体框架问题在VS2012 - 重命名属性不坚持 [英] Entity Framework Issue in VS2012 - Rename Properties not Sticking

查看:407
本文介绍了实体框架问题在VS2012 - 重命名属性不坚持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建在VS2012一个新的项目,行政MVC4项目,网站MVC4项目,一个共同的实体框架DLL项目。

I was attempting to create a new project in VS2012 with an Administrative MVC4 project, Website MVC4 project, and a Common Entity Framework dll project.

我用现有的数据库的数据库并从中产生我的实体。我更新的一些关系属性的名称和保存。然后,我加入到实体框架项目,我的两个MVC4项目的引用,从App.config中fileto每个Web.config文件中的复制实体框架的连接字符串,并确保我引用相同System.Data.Entity的组件所有3个项目。

I used an existing database an database and generated my entities from it. I updated the names of some of the relation properties and saved. I then added references to the Entity Framework project to both of my MVC4 projects, copied the Entity Framework connection string from App.config fileto each of the Web.config files, and made sure I was referencing the same System.Data.Entity assembly in all 3 projects.

我尝试添加使用实体框架的MVC控制器并收到一个错误。该错误指出,我的实体没有与某些名称属性。正巧有人发牢骚是我在实体设计改名的人的名字。于是我就清理解决方案,重建,并试图再次添加控制器......同样的错误。

I tried to add an MVC Controller using Entity Framework and received an error. The error stated that my entities did not have properties with certain names. It just so happened the names it was griping about were the ones that I renamed in the Entity Designer. So I ran Clean Solution, rebuilt, and attempted to add the controller again...Same error.

由于这是抱怨它没有与某些名称的属性,我用ILSpy检查已生成的程序集。果然,它没有结转我分配给实体设计的属性的名称。下面是设计界面的表现(是的,我救了它),我改名类的照片,该错误信息尝试添加的MVC控制器时,我获得,并显示出的属性没有在正确输出更名为ILSpy输出组装。

Since it was complaining that it didn't have properties with certain names, I used ILSpy to inspect the assembly that was generated. Sure enough, it did not carry over the names I assigned to the properties in entity designer. Below is a photo of the Designer interface showing that I renamed the classes (yes I saved it), the error message I was getting when attempting to add the MVC controller, and the ILSpy output showing that the properties were not properly renamed in the output assembly.

这是一个错误吗?难道我做错了什么?

Is this a bug? Am I doing something wrong?

更新:看来.TT文件不会自动触发和再生的实体,当我做出改变的.edmx设计。不知道我需要做的就是当我保存的EDMX他们自动运行?

Update: It seems the .tt files are not automatically firing and regenerating the entities when I make changes to the .edmx design. Not sure what I need to do to get them to run automatically when I save the edmx?

推荐答案

有是rel=\"nofollow\">报告的bug 这会导致这个问题的时候EDMX是不是在项目目录的根目录。当您将EDMX成子文件夹,您必须手动运行自定义工具来重新生成类。

There is reported bug which causes this issue when EDMX is not in the root of project directory. When you place EDMX into sub folder you must manually run custom tool to regenerate classes.

这篇关于实体框架问题在VS2012 - 重命名属性不坚持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆