Entity Developer generates ID attribute

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
Jakobvj
Posts: 5
Joined: Thu 30 Jul 2015 06:29

Entity Developer generates ID attribute

Post by Jakobvj » Wed 14 Feb 2018 11:06

Hi
Hope someone can help me.
Im trying to make a model, and then generate code-first code.
Like this:
https://ibb.co/gEtGo7

The problem is that when I make a association Entity Developer generates a ID attribute.
So when I generate the code-first code, the ID attribute is also there, but also the navigation property.

Is the ID necessary?

Regards
Jakob

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

Re: Entity Developer generates ID attribute

Post by Shalex » Fri 16 Feb 2018 15:08

Please give us the following information:
1) you want not to add a foreing key property (CityId) to the child class (Customer) when creating an association, don't you?
2) do you need to avoid creating a class property (in model) or a table column (in database)?
3) the name of your ORM (EF6 *.edml, EF Core *.efml, etc)
4) a target database server (SQL Server, Oracle, etc)

Jakobvj
Posts: 5
Joined: Thu 30 Jul 2015 06:29

Re: Entity Developer generates ID attribute

Post by Jakobvj » Sun 18 Feb 2018 10:08

Hi Shalex
1. Yes
2. I don't want the class property (CityID). Dont care about if its in the database
3. EF6
4. SQL Server

Regards

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

Re: Entity Developer generates ID attribute

Post by Shalex » Tue 20 Feb 2018 18:58

Please open Model Settings and clear selection of the "Include foreign key columns in the model" option. Does this help?

Jakobvj
Posts: 5
Joined: Thu 30 Jul 2015 06:29

Re: Entity Developer generates ID attribute

Post by Jakobvj » Fri 23 Feb 2018 19:18

That did´nt help.. Still generates the property...

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

Re: Entity Developer generates ID attribute

Post by Pinturiccio » Mon 26 Feb 2018 14:34

Jakobvj wrote:That did´nt help.. Still generates the property...
Have you recreated your objects after you cleared the "Include foreign key columns in the model" check box?
Please also provide the following information:
1. When exactly the CityId property is added?
2. Do you generate the model from a database or do you add classes, associations, etc. yourself?

If you build the model from the database, you need to generate these classes again after clearing the check box. Delete the classes from the model and add them again.
If you create classes and associations manually, open Mapping Details for an association and configure its mapping. After this, delete this property from the class. When adding classes from the database, this is done automatically.

Jakobvj
Posts: 5
Joined: Thu 30 Jul 2015 06:29

Re: Entity Developer generates ID attribute

Post by Jakobvj » Wed 28 Feb 2018 10:17

Yes, I can see the foreign key is not included when making a model from the database...

Is it correct, that after creating the association, I can just delete the key from the model?

I just don't see a reason why the id is added when I have NOT checked the include foreign key in model

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

Re: Entity Developer generates ID attribute

Post by Pinturiccio » Wed 28 Feb 2018 10:47

Jakobvj wrote:Is it correct, that after creating the association, I can just delete the key from the model?
Yes, you can delete the key and configure the association.
Jakobvj wrote:I just don't see a reason why the id is added when I have NOT checked the include foreign key in model
We will investigate this situation and post here about the results.

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

Re: Entity Developer generates ID attribute

Post by Shalex » Fri 30 Mar 2018 17:28

The bug with applying the "Include foreign key columns in the model" model setting by Create Model Wizard is fixed (SQL Server): https://www.devart.com/entitydeveloper/ ... story.html.

Post Reply