从数据库更新模型的实体框架错误,反之亦然 [英] Entity framework error on updating model from database and vice versa
问题描述
当我尝试使用VS express 2013的Web,EF6.1.1和.NET框架4.5从数据库更新模型时,会发生什么。
在这种情况下我刚刚在表格定义中添加了一个字段,并更新了数据库。
之后我右键单击EDMX模型视图中的数据库更新模型,错误消息:
尝试从数据库更新时发生类型System.runtime.interopServices.COMException
的异常。
的异常消息是:'名称为'Model.Context.tt'的文件或文件夹已经存在
。请给您添加或删除
现有项目的项目唯一的名称。
我注意到我得到我尝试从模型生成数据库时出现相同的错误消息。
我尝试了以下方法:
- 如何更新具有数据库更改的edmx文件?
- http://blog.jongallant.com/2012/08/entity-framework-manual-update.html#.VMYYRv7A7mH
但没有一个工作。
我还发现 https://entityframework.codeplex.com/workitem/1104 ,似乎已经通过commit 7 e8331d1d22d(EFTools repo)。
任何人都可以帮助我解决我的问题,还有什么是commit 7e8331d1d22d(EFTools repo)? b
$ b
谢谢
Boid'
这是一个老问题,但我遇到同样的问题。最后在这个错误报告。检查是否有任何* .tt文件未添加到解决方案中并将其删除。这解决了我的问题。
Here is what happens when I try to update model from database with VS express 2013 for the web, EF6.1.1 and .NET framework 4.5.
In this case I just added a field to a table in the table definition and updated the database.
After that I right click update model from database in the EDMX model view and I get this error message:
An exception of type ‘System.runtime.interopServices.COMException’ occurred while attempting to update from the database. The exception message is: ‘A file or folder with the name ‘Model.Context.tt’ already exists. Please give a unique name to the item you are adding or delete the existing item first.
I noticed that I get the same error message when I try to generate the database from the model.
I tried the following methods:
- How do you update an edmx file with database changes?
- http://blog.jongallant.com/2012/08/entity-framework-manual-update.html#.VMYYRv7A7mH
but none of them worked.
I also found that https://entityframework.codeplex.com/workitem/1104 and it seems that it has been resolved with "commit 7e8331d1d22d (EFTools repo)".
Anyone can help me on how to solve my problem or on what is "commit 7e8331d1d22d (EFTools repo)" ?
Thanks
Boid’
It's an old question but I just run into the same issue. Finally found a solution in this bug report. Check if you have any *.tt files that are not added to solution and remove them. That fixed the problem for me.
这篇关于从数据库更新模型的实体框架错误,反之亦然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!