Adding a New Column to an Existing Table in Entity Framework

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.

  1. So in Windows Exlorer, right-click on the *.edmx file and open with Notepad (or Notepad++/Textpad).

  2. Search for the text <EntityType Name="YourTableNameToAddColumn">.

  3. Add the property <Property Name="YourNewColumnName" Type="varchar" MaxLength="64" />

  4. Search for the text <MappingFragment StoreEntitySet="YourTableNameToAddColumn">

  5. Add mapping to the new column <ScalarProperty Name="YourNewColumnName" ColumnName="YourNewColumnName"/>

  6. Save the *.edmx file

Leave a Comment