SmashCode
SmashCode

Reputation: 4257

Updating Entity Framework Model after adding a field to a previous look up only table

To better illustrate the problem :

I have a table called Action with key AID and I have a table called Requirement with RID.

Previously I had a lookup table that simply held an AID and an RID.

This was fine, Action had a navigation property Requirements and Requirement had a navigation property Actions.

I added a field called Weight to the lookup table called Requirement_Fulfillment.

I updated the model from database. I ran the custom tool.

The model doesn't show a table for Requirement_Fulfillment. The two tables (Action and Requirement) still see each other as simply navigation properties.

Anyone know what I'm doing wrong?

Upvotes: 1

Views: 2120

Answers (3)

qxn
qxn

Reputation: 17584

You used to have a mapping, and now you have a new entity.

You'll probably have to delete the relationship between Action and Requirement in the designer. Then update your model from the database, and make sure the lookup table is checked in the Tables branch of the Add tab. Then you should have a new entity based on the lookup table, and the Action and Requirement entities will have a relationship with that entity (instead of having a direct mapping to each other).

If the lookup table doesn't show up in the update wizard, you might try manually deleting any reference to the table in the .edmx file.

Upvotes: 3

Christian Phillips
Christian Phillips

Reputation: 18769

Try a refresh of the tables or simply delete tables from the designer and re-add them.

Upvotes: 0

E.J. Brennan
E.J. Brennan

Reputation: 46879

I always delete tables from my model, and then add them back in to get the latest updates from the DB; I think its the only reliable method (assuming you are using DB first). 'Update model from database' doesn't do what its name implies.

Upvotes: 0

Related Questions