Gary Gary - 2 months ago 19
C# Question

Exception when refreshing EF designer

new to Entity Framework....

I am currently using the latest update for EF and Visual Studio 2012, when trying to refresh from the database to update tables in my model that have changed, the designer is throwing a COMException "A file or folder with the name 'XXXXModel.Context.tt' already exists. Please give a unique name to the item our are adding.

It looks like it wants me to delete all my model files when refreshing from DB, this can't be right. Am I missing something?

Answer

This happens because entity framework creates your model in an auto generated container.designer.cs file. This file contains classes that map with your database tables.

On this occasion, don't delete the model but only delete .tt files

Comments