8

I generated an .edmx file from database.

I want to know if I make changes to my database schema then how will those changes be reflected in my Entity Data Model Designer diagram? I made changes to my database schema but found the changes did not appear in my Entity Data Model Designer diagram. Can someone explain to me how to propagate database schema changes to my Entity Data Model Designer diagram?

MattC
  • 3,984
  • 1
  • 33
  • 49
Thomas
  • 33,544
  • 126
  • 357
  • 626
  • possible duplicate of [Updating your edmx to reflect changes made in your db (.net linq-to-entities)](http://stackoverflow.com/questions/690248/updating-your-edmx-to-reflect-changes-made-in-your-db-net-linq-to-entities) – Tim Abell Dec 05 '14 at 10:51

5 Answers5

19

I think what you are asking is if you change your schema, how is this then updated in your EDMX file?

  1. Open your EDMX file in Visual Studio
  2. Right click on the design surface
  3. Select 'Update Model from Database'
  4. Follow the wizard to 'Refresh' your model.

Your changes should now be visible on the design surface in the respective containers.

MattC
  • 3,984
  • 1
  • 33
  • 49
  • thanks for ur answer but i did change the field data type and Update Model from Database but change did not refelect in edmx file. what to do? – Thomas Mar 25 '11 at 13:21
  • When you clicked the Refresh tab did the tree view list your table to be updated? Are you sure you are connecting to the same database you made the changes on? How are you checking to see the changes? – MattC Mar 25 '11 at 13:24
  • @Ladislav - Ah, yes I see what he is asking, with regards to seeing the field type change. – MattC Mar 25 '11 at 14:20
  • Hey @MattC How can we update around 20+ edmx files via code? any tips?? – Muhammedh Aug 13 '14 at 12:03
  • This question was related to EF4 for VS2010, so it's quite old now. I suggest you open a new question, perhaps linking to this to illustrate what you want to acheive. – MattC Aug 13 '14 at 17:12
6

so i want to know if i add or remove any field from table then how change will be reflected in my Entity Data Model Designer where diagram show.

Additions in your tables will be reflected in your model if you "Update Model From Database" as posted in the other answers. If you delete tables or columns though in my experience you have to remove the corresponding entity manually from your model and then update the model from the database.

BrokenGlass
  • 158,293
  • 28
  • 286
  • 335
  • 1
    +1 This is correct answer. Updating from database does not remove or change existing definitions in conceptual model (that is what you see in designer). – Ladislav Mrnka Mar 25 '11 at 13:18
2

Right click in the edmx, click "Update Model From Database". Go over to the "Refresh" tab, and click "Finish".

Martin
  • 11,031
  • 8
  • 50
  • 77
2

You need to open up your model and right click on an empty space and select Update Model from Database...

Aducci
  • 26,101
  • 8
  • 63
  • 67
1

When using 'Update from Database' you can also select whether to add new tables from your database if required, or leave them out.

finoutlook
  • 2,523
  • 5
  • 29
  • 43