Page 1 of 1

Duplication error when using the dbContext!! Template?

Posted: Mon 11 Sep 2017 22:54
by alfredo.avmb
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

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

Posted: Tue 12 Sep 2017 10:21
by Shalex
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.

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

Posted: Tue 12 Sep 2017 21:13
by alfredo.avmb
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

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

Posted: Tue 19 Sep 2017 11:28
by Pinturiccio
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.

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

Posted: Thu 21 Sep 2017 16:17
by alfredo.avmb
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

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

Posted: Wed 27 Sep 2017 15:36
by Shalex
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.

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

Posted: Wed 27 Sep 2017 15:48
by alfredo.avmb
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

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

Posted: Thu 28 Sep 2017 11:50
by Shalex
Please specify a code snippet you use with ObjectContext descendant which you cannot rewrite for using DbContext descendant.