Solved

One I have created an Entity Model, how do I resync with database?

Posted on 2010-09-24
4
256 Views
Last Modified: 2012-06-27
Using Visual Studio 2010 and Entity Framework 4.0, I need to sync up the Entity with the latest database.

I made changes with new tables, etc.  How do I get a new Entity?  Do I delete and recreate?

How do I make sure that I do not lose any of my code?

Thanks,
newbieweb
0
Comment
Question by:newbieweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 350 total points
ID: 33756929
Hi newbieweb;

To the question, "How do I get a new Entity?", Right click on the Model design surface and from the context menu click on "Update Model from Database". When the Update Wizard is finished loading click on the Add tab to add new tables, views and SP's, click on the Refresh tab to update the current tables in the model with the database new versions of tables, views and SP's, and the Delete tab to delete tables, views and SP's.

To the question, "Do I delete and recreate?" , no see answer above.

To the question, "How do I make sure that I do not lose any of my code?", as long as you have not been modifying the auto-generated code produced by the wizard it will not be lost.

Fernando
0
 
LVL 16

Assisted Solution

by:SriVaddadi
SriVaddadi earned 150 total points
ID: 33757023
You can syn the Entity model from database as below

1. Open the edmx file (right click in the solution explorer)
2. Right click on the empty area and click "Update model from database" or you could do the same thing from Model Browser.

If you have made any changes to the Entity model generated code then you would loose your  changes updating the entity model

To keep your changes when you update the model

1. Create a partial class for the entity you want to modify and add ur code to your partial class instead of modifying the auto generated code.

* DO NOT MODIFY THE AUTO GENERATED CODE. YOU WILL LOOSE THOSE CHANGES
0
 

Author Closing Comment

by:newbieweb
ID: 33757203
Thanks.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 33757278
Not a problem, glad I was able to help.  ;=)
0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question