Solved

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

Posted on 2010-09-24
4
249 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
  • 2
4 Comments
 
LVL 62

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 62

Expert Comment

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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ASP:DataGrid and how to bind to a BoundColumn 8 30
String manipulation 15 49
ASP.NET reading ATOM 2 27
Birthdays 3 22
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now