I have added a new column to a table in my database. The table is already defined in the existing Entity Framework model. I've been through most of the items here on how to do this and it still fails.
A little background, this entity model has not been updated in at least 3 years. So aside from the column I'm adding I know there have been a number of other columns that have been added in that time, but never included. I took over the project about 9 months ago and have never been able to successfully update the model.
First attempt:
Result:
Second Attempt
Result
Third Attempt
Result
Fourth Attempt
Results
Final Attempt
Result
Any help or direction that could be provided would be greatly appreciated as I'm at a critical point and have to get the model updated.
The "Update Model from Database" is hard/slow to use and is prone to errors. It generates other stuff that you probably don't want/need. So manually adding the column that you need will work better. I suggest you do it outside the VS editor since depending on how many models/tables, it can be very slow opening the file in VS.
So in Windows Exlorer, right-click on the *.edmx
file and open with Notepad (or Notepad++/Textpad).
Search for the text <EntityType Name="YourTableNameToAddColumn">
.
Add the property <Property Name="YourNewColumnName" Type="varchar" MaxLength="64" />
Search for the text <MappingFragment StoreEntitySet="YourTableNameToAddColumn">
Add mapping to the new column <ScalarProperty Name="YourNewColumnName" ColumnName="YourNewColumnName"/>
Save the *.edmx
file