I have two tables with below structure :
*Table User*
id int identity
username varchar
role varchar
*Table Ticket*
id int identity
admin_id int
user_id int
admin_id
and user_id
are the foreign keys from User
table.
I set a relation name for the relations in Mssql diagram, but when i create my model from this database, the relations are : User
and User1
.
When I'm changing them manually, it is going Ok, but after refreshing the model or re-create the Ticket
table, User
and User1
are back.
How can i set the final name for my relations in EF model?even i refresh or delete the entire model, i want to the EF Model relation name are being same as the diagram relation name.
There is no way to force Entity Framework to get names of properties from relation names, instead it takes table name as property name (with integer suffix for multiple properties).
Now the issue, in your scenario is that your renamed properties change to their original names when ever you update model from database
.
We can stop entity framework
to do not reset property names which we renamed them by our own. The way is,
Association
folder in model browserProperty
pallet, start searching End2 Navigation
Property
from bottom.that is done.
Now, it will not be refreshed even you update model from database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With