Entity Framework (ASP.NET): How do you update the column mapping after adding a column to the framework?
I added a column to the Entity and then I go to generate the d开发者_运维问答atabase from the model or build the solution and I get the message that the new column I just added is not mapped. The database was previously created from the model with no errors.
When I right click on the Entity and select Table Mapping, I can see the old columns there mapped but I don't see a way to m
The only way I've found to resolve it without "update model from database" (what causes other issues in my legacy project) is to edit the .edmx file with the XML editor, add the property (Name and Type) to the EntityType and save. After that when I open the .edmx editor the added property is there for mapping.
The easiest way to resolve this issue is to right click on the Entity Model and choose "Update Model From Database". Then select the "Refresh" tab and find and select only the table you wish to map a column for. Click the Finish button and you should have everything properly mapped. If you notice a duplicate column in you Entity, just delete the one you previously created and rename the new column to your liking. It's pretty frsutrating that Microsoft doesn't let you manually add just one column mapping.
If you are just trying update a single parameter, you can open the file Model.edmx and change this single parameter, but if is more than one parameter it's better the option "update from database". It's important note that table mapping can't be changed using VS.
Refreshing did not work for me as the other answers suggest, or editing the .edmx directly as xml. Delete the model and pull it again from the database (with "Add new").
精彩评论