locked
how can I change/update model a table ? RRS feed

  • Question

  • User-1357109602 posted

    I added/changed column to table, how I can now change/update model for this table ?

    Thursday, June 25, 2009 8:38 AM

Answers

  • User1904378495 posted

    If you're using the entity framework (like that tutorial) you can update the model by following these steps

    • Expand the Models folder and double click the .edmx file (in this case "MoviesDBModel.edmx")
    • On the design surface right click on the Movie entity. Select "Update Model from Database"
    • Select the "Refresh"Tab and expand the "Tables" folder
    • Select Movies and hit "Finish"

    You will notice the Movie entity on the surface should contain your extra database column as a property now. After you save your changes you have to manually add the new property to your html table in the View. After that recompile and everythign should work fine.


    If you're using linq to sql you have to refresh the table in server explorer, then delete the model from the design surface and drag it back on.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 25, 2009 11:57 AM

All replies

  • User371048076 posted

    Can you give some more infos? How do you add the column? server-side or client side? how your model is build?

    Thursday, June 25, 2009 8:58 AM
  • User-1357109602 posted

    I used that tutorial: http://www.asp.net/learn/mvc/tutorial-21-cs.aspx to create 1 table like in this tutorial. I am interested what I should do when I add or change some column in this table - I must update generated model but how ?

    Thursday, June 25, 2009 9:35 AM
  • User-1357109602 posted

    Really noboty knows ? I think this is very very important because eveybody sometimes needs modify same table in database. The best solution then is to delete this model and create new ?

    Thursday, June 25, 2009 11:43 AM
  • User1904378495 posted

    If you're using the entity framework (like that tutorial) you can update the model by following these steps

    • Expand the Models folder and double click the .edmx file (in this case "MoviesDBModel.edmx")
    • On the design surface right click on the Movie entity. Select "Update Model from Database"
    • Select the "Refresh"Tab and expand the "Tables" folder
    • Select Movies and hit "Finish"

    You will notice the Movie entity on the surface should contain your extra database column as a property now. After you save your changes you have to manually add the new property to your html table in the View. After that recompile and everythign should work fine.


    If you're using linq to sql you have to refresh the table in server explorer, then delete the model from the design surface and drag it back on.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 25, 2009 11:57 AM
  • User-1357109602 posted

    Thx you very much - this is that what I wanted :)

    Thursday, June 25, 2009 12:19 PM