Page 1 of 1

Entity Developer generates ID attribute

Posted: Wed 14 Feb 2018 11:06
by Jakobvj
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

Re: Entity Developer generates ID attribute

Posted: Fri 16 Feb 2018 15:08
by Shalex
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)

Re: Entity Developer generates ID attribute

Posted: Sun 18 Feb 2018 10:08
by Jakobvj
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

Re: Entity Developer generates ID attribute

Posted: Tue 20 Feb 2018 18:58
by Shalex
Please open Model Settings and clear selection of the "Include foreign key columns in the model" option. Does this help?

Re: Entity Developer generates ID attribute

Posted: Fri 23 Feb 2018 19:18
by Jakobvj
That did´nt help.. Still generates the property...

Re: Entity Developer generates ID attribute

Posted: Mon 26 Feb 2018 14:34
by Pinturiccio
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.

Re: Entity Developer generates ID attribute

Posted: Wed 28 Feb 2018 10:17
by Jakobvj
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

Re: Entity Developer generates ID attribute

Posted: Wed 28 Feb 2018 10:47
by Pinturiccio
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.

Re: Entity Developer generates ID attribute

Posted: Fri 30 Mar 2018 17:28
by Shalex
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.