问题
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’
回答1:
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.
来源:https://stackoverflow.com/questions/28153536/entity-framework-error-on-updating-model-from-database-and-vice-versa