The newly added object is in the local DataSource, since it’s not persisted yet in the database,
so you may say:
EntityObject search = ents.EntityObject.FirstOrDefault(o => o.Id == theId) ??
ents.EntityObject.Local.FirstOrDefault(o => o.Id == theId);
More Related Contents:
- Improving bulk insert performance in Entity framework [duplicate]
- ORM Entities vs. Domain Entities under Entity Framework 6.0
- Unique Constraint in Entity Framework Code First
- How do I detach objects in Entity Framework Code First?
- Entity Framework validation with partial updates
- Solution for “Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details.”
- NOT using repository pattern, use the ORM as is (EF)
- How do you update an edmx file with database changes?
- Cascading deletes with Entity Framework – Related entities deleted by EF
- Entity framework core update many to many
- EF Query With Conditional Include
- Package Manager Console Enable-Migrations CommandNotFoundException only in a specific VS project
- Entity Framework CTP 4 – Code First Custom Database Initializer
- How do I singularize my tables in EF Code First?
- Set decimal(16, 3) for a column in Code First Approach in EF4.3 [duplicate]
- How can I disable code first migrations
- ObjectContext.Refresh()?
- How do I map a char property using the Entity Framework 4.1 “code only” fluent API?
- An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key
- Stuffing an anonymous type in ViewBag causing model binder issues
- EntityFramework Core automatic migrations
- What is the syntax for self referencing foreign keys in EF Code First?
- check constraint entity framework
- int to string in Entity Framework
- Entity Framework 4.0: Error 113: Multiplicity is not valid in Role
- Paging in Entity Framework
- Using SimpleMembership with EF model-first
- Entity Framework: Inheritance and Include
- Entity Framework – Get List of Tables
- Entity framework code first delete with cascade