This project is read-only.


[Error] An item with that name already exists


Hi there,

I've some problems when generating DTOs from my model. EntitiesToDTOs gives me the following error message which I tried to translate from german language:

Message: An item with that name already exists "ArticleType_ID"

Original error in log file:
2013.01.24 13:59:07 (UTC) [ERROR]
Es ist bereits ein Element mit dem Namen "ArticleType_ID" vorhanden.
   bei Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CCodeModelBase.ThrowCustomError(Int32 hr, String elementName)
   bei Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CCodeTypeBase.AddMember[T](String pszName, Object vtPosition, MEMBERKIND iKind, Name pKey, Object[] args)
   bei Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CCodeTypeBase.AddPropertyImpl(String bstrGetterName, String bstrPutterName, Object vtType, Object vtPosition, vsCMAccess Access)
   bei Microsoft.VisualStudio.CSharp.Services.Language.CodeModel.CCodeClass.AddProperty(String bstrGetterName, String bstrPutterName, Object vtType, Object vtPosition, vsCMAccess Access, Object vtLocation)
   bei EnvDTE.CodeClass.AddProperty(String GetterName, String PutterName, Object Type, Object Position, vsCMAccess Access, Object Location)
   bei EntitiesToDTOs.Generators.DTOGenerator.GenerateDTOs(GenerateDTOsParams parameters, BackgroundWorker worker)
   bei EntitiesToDTOs.Generators.GeneratorManager.Generate_DoWork(Object sender, DoWorkEventArgs args)
Is there a problem with my Model (See attached edmx file) or a bug in EntitiesToDTOs?

Thanks a lot



file attachments

Closed Jul 10, 2013 at 4:31 AM by ffernandez


ffernandez wrote Jan 24, 2013 at 3:23 PM

Hi @Scheurich !

Thanks a lot for providing all the details.

I was able to test your issue, I noted that it happens with your model when DTOs Association option is Key Properties.
This happens because Article entity has a property ArticleType_ID and also an association to ArticleType. EntitiesToDTOs will add to ArticleDTO a property named ArticleType_ID and the association to ArticleType will be maped in the DTO using the Key Property of ArticleType which is named ID, then will generate a name for this association property in the DTO and it is composed using format EntityName_KeyPropertyName finally generating ArticleType_ID which was already used by another property.

The solution to this would be to use Class Types Association for DTOs and you end up having which I think you want which is in ArticleDTO a property named ArticleType_ID and another property named ArticleType of type ArticleTypeDTO (this is the association).

Nevertheless, I will work on the issue because I don't want to produce an Exception when this type of issue happens, I want a more descriptive message.

Let me know if the solution fits your needs, if not let me know so I can rethink it again of what would be the best for all.

Thanks again!

wrote Jan 24, 2013 at 3:24 PM

Scheurich wrote Jan 25, 2013 at 7:03 AM

Hello Fabian,

thank you for your fast response! Using Class Types Association did the trick.

Keep it up!



wrote Feb 22, 2013 at 12:03 AM

wrote Jul 10, 2013 at 4:01 AM

Associated with changeset 25512: Fixed Work Item #1003.

wrote Jul 10, 2013 at 4:31 AM