Solved

Can I see new   added   Entity before calling  SaveChanges method

Posted on 2014-11-17
1
72 Views
Last Modified: 2014-12-09
I have Table Orders
I should allow user to add new Order , fill out it first and then Save Changes to to Database
I am working in EF5

how to I insert Entity  in  Entity Context before calling SaveChanges method?
Thanks.
0
Comment
Question by:Yampolka
1 Comment
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40448439
You can do something like this.

DcContextInstanceName.EntityTableName.Add(newlyCreatedEntity);

db.Orders.Add(newOrder);

Where db is the instance of the DbContext Orders is the entity class that maps to the database and newOrder is an instance of the Order table entity.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

815 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

7 Experts available now in Live!

Get 1:1 Help Now