Duplication error when using the dbContext!! Template?

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
alfredo.avmb
Posts: 10
Joined: Wed 23 Aug 2017 04:07

Duplication error when using the dbContext!! Template?

Post by alfredo.avmb » Mon 11 Sep 2017 22:54

Duplication error when using the dbContext!! Template?

When adding to my data model, the dbContext template and previously generate the output of the entities and the context, this sends me an error message when saving or when regenerating my project.

Severity Code Description Project File Line Status deleted
Error CS0111 The type 'SIAFEntities' already defines a member named '.ctor' with the same parameter types siafentitymodel E: \ GIT \ siaf \ siafentitymodel \ SIAFModel.SIAFEntities.cs 41 Active

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: Duplication error when using the dbContext!! Template?

Post by Shalex » Tue 12 Sep 2017 10:21

Please remove all *.cs files created by DbContext template and resave the *.edml model to regenerate them again. This should fix the issue.

Most likely you generated the code, then set Generate Partial Class=True (DbContext template's property) which leaves unchanged existing %ModelName%.%ClassName%.cs and generates new *.Generated.cs.

alfredo.avmb
Posts: 10
Joined: Wed 23 Aug 2017 04:07

Re: Duplication error when using the dbContext!! Template?

Post by alfredo.avmb » Tue 12 Sep 2017 21:13

The dbContext and EntityObject templates can work on the same model. I ask if I can work this two or is another cause the error sent me by which I asked the question.

regards

Pinturiccio
Devart Team
Posts: 2192
Joined: Wed 02 Nov 2011 09:44

Re: Duplication error when using the dbContext!! Template?

Post by Pinturiccio » Tue 19 Sep 2017 11:28

alfredo.avmb wrote:The dbContext and EntityObject templates can work on the same model.
These templates generate partially similar classes to the same locations. You can use one of the following solutions:
1. Use different models with different namespaces.
2. Configure output for templates so that they output code to different projects.

alfredo.avmb
Posts: 10
Joined: Wed 23 Aug 2017 04:07

Re: Duplication error when using the dbContext!! Template?

Post by alfredo.avmb » Thu 21 Sep 2017 16:17

This is my current work outline or structure in my project:

In the solution, the model name is SIAFMODEL

I have two folders one with the name Context and Entities where I store or indicate the output to the EntityObject template.

A third folder that calls you DBContext, with two more folders called Context and Entities for the DbContext template.

As you can see, I send the output of each of them to different folders, I would like to send them an image if necessary, I am using the DBContext template in the help or link that they sent me indicated that to work with the properties of the context, use this template, my problem is that I can not get the properties to know whether or not to change the status of a record, I understand that with this template I can work the states.

If with this I resolve and I will not need the EntityObject template please indicate me.

Thank you very much and I hope to have explained or given to understand.

regards

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: Duplication error when using the dbContext!! Template?

Post by Shalex » Wed 27 Sep 2017 15:36

1. With two templates (EntityObject and DbContext), you generated two classes with the same namespace and name. That's why you are getting the original error.
alfredo.avmb wrote:my problem is that I can not get the properties to know whether or not to change the status of a record, I understand that with this template I can work the states.
If with this I resolve and I will not need the EntityObject template please indicate me.
2. You can track the entity state with the code generated by the DbContext template as well: https://msdn.microsoft.com/en-us/librar ... 13%29.aspx.

alfredo.avmb
Posts: 10
Joined: Wed 23 Aug 2017 04:07

Re: Duplication error when using the dbContext!! Template?

Post by alfredo.avmb » Wed 27 Sep 2017 15:48

Hello, that link had already been reviewed or sent to me, my problem or query is that it does not give me the properties of the entity in the context, I could indicate a link or give me an example of how to work the two templates that I mention in my mail and an example of working or calling entities in this context.

I feel that I continue with the same problem despite my inquiries, I would appreciate it if you can help me with my request to close this case, with the two examples or give me a link to see the two templates working plus the properties of the entity with the ORM or EF.

Again thank you for your help or answers to my emails, thank you very much if you respond to me soon because I am already urgent or desperate with this problem or lack of knowledge of the tool on my part.

regards

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Re: Duplication error when using the dbContext!! Template?

Post by Shalex » Thu 28 Sep 2017 11:50

Please specify a code snippet you use with ObjectContext descendant which you cannot rewrite for using DbContext descendant.

Post Reply