?
Solved

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

Posted on 2010-09-24
4
Medium Priority
?
257 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 1400 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 600 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
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…
Suggested Courses

777 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