The name of the first EF database role with foreign keys?

I am using EF Database First. In db, we have a lot of fk from one table to another (same thing). When creating a model, EF uses the table name of the other ends as the role name. This is problem. I will give a small example below to illustrate the problem.

I would like the generated code to use the name fk, not the name of the table. The VS model now generates like this:

aTrip.Location
aTrip.Location1
aTrip.Location2

when i would like to have

aTrip.coming_from
aTrip.arrives_to
aTrip.next_dest

Now I can change the role names in VS. The problem is that if I re-import, all my changes will be lost. In addition, there will be a lot of tedious renaming, since our db contains a lot of fk, like this example.

I would like to change how VS generates the model, and use the name fk col, which is much more correct. It can be done?

+----------------+                   +-------------+
|    Trip        |                   |Location     |
+----------------+                   |             |
|                |                   +-------------+
|                |                   |  Name       |
|                |*                 1|             |
|   coming_from  ---------------------             |
|                |                   |             |
|                |                   |             |
|                |*                 1|             |
|   arrives_to   ---------------------             |
|                |                   |             |
|                |                   |             |
|                |*                 1|             |
|    next_dest   ---------------------             |
|                |                   |             |
+----------------+                   +-------------+
+3
1

, , , .

, . , , ! - , , .

, , . , , .

. , , , .

, , , .

, , , !

0

All Articles