FAQS‎ > ‎

Entity Framework FAQ

  1. Architecture
    1. What are the key justifications to Entity Framework as ORM solutions.
    2. Why we should use ORM framework at all.
    3. In what type of application we should use entity framework.
    4. What are the performance consideration of using entity framework.
    5. Can entity framework handle bulk transaction and high volume of concurrent transactions
  2. Conceptual Models 
    1. Does the Entity Framework support abstract types in EDM models?
    2. Does the Entity Framework have support for complex types? What are complex types? How are they different from entity types in the EDM?
    3. Does the Entity Framework support multiple entity sets per type? Why is "multiple entity sets per type" support required?
    4. Are associations between subtypes supported?
    5. Does the EDM support GUIDs?
    6. Does the EDM/EF support enums?
    7. Does the Entity Framework allow embedding metadata files as resources in the assembly?
    8. When is the EDMX file used? What is the difference between the EDMX file and the three schema files (CSDL, MSL, and SSDL)?
    9. How is the "using" support in metadata files used?
    10. Is it possible to create queries that extend across multiple object contexts (o-space) and/or entity connections (c-space)?
    11. Can custom annotations be added in the CSDL file?
  3. Mapping 
    1. How can I map a stored procedure?
    2. How can I map read-only entities? How can I use Defining QueryViews in mapping files?
    3. When doing model first, how can I customize the DDL script generated from my model?
    4. I never delete records from my tables, but I do have a flag that indicates whether a record is active or not. I never want to show the records that are not active on the client. How do I permanently filter them out?
    5. Is it possible to map views to complex types?
    6. Is there a way to specify default values for columns? Some DateTime columns in my database are set to getdate(), but the EF is unaware of these default values.
    7. Is there any way to map a stored procedure to an association set in the designer?
    8. DefiningQuery versus QueryView
  4. Entity Sets 
    1. Is it required to use the code generation tool? Can I hand-author entity classes?
    2. Is it recommended to modify tool-generated classes?
    3. Does the Entity Framework require objects with public empty constructors?
    4. Does the Entity Framework require objects with public accessors for properties that are to be stored in the database? Does the Entity Framework support read-only properties?
    5. Does the Entity Framework support a private field to be mapped to the database?
    6. Does the Entity Framework support inheritance for methods or properties that do not map to the database?
    7. What are the entity types supported by the Entity Framework?
    8. When should I use self-tracking entities and when are EntityObject derived types or POCO classes a better choice?
    9. Why does a self-tracking entity's state not get updated to Modified after its property has been modified on the client?
    10. How can I store a set of self-tracking entities in ViewState for an ASP.NET application?
    11. Where can I find a graph iterator solution for self-tracking entities?
    12. How can I avoid getting objects with duplicate keys in the graph when working with self-tracking entities?
    13. How can I use self-tracking entities in Silverlight?
    14. Why doesn't Function Import work when generating code with the Self-Tracking Entity Generator Template?
    15. How do I know what change-tracking strategy is used: change tracking with proxies or snapshot?
    16. Why are my entities not change-tracking proxies, even though all the properties are virtual?
    17. How are complex type properties tracked in POCO proxies?
    18. Are there any performance considerations when using POCO?
    19. Are pre-generated views available when working with POCO?
    20. What are different options to customize entity objects?
    21. Does the Entity Framework support cloning of entity objects or do I have to do it manually?
  5. Relationships and Entity Mapping 
    1. Does theEntity Frameworksupport lazy loading and deep loading, and how is the performance for these features?
    2. Is it possible to make the EF implicitly load related entities? Is lazy loading enabled by default?
    3. Is there a topic that compares foreign key association and independent association?
    4. How do I change independent associations to foreign key associations?
    5. Are changes to relationships in my objects always synchronized in the state manager?
    6. Can I load related objects on a detached entity?
    7. What are different ways to create and modify relationships?
    8. What is the difference between the Load method and the LoadProperty method?
    9. When I call LoadProperty with an overload that takes a lambda expression in Visual Basic, I get the "The selector expression for LoadProperty must be a MemberAccess for the property" error. Is this a known issue?
    10. How do I get notified when an item is added to the collection?
    11. Does the Entity Framework support associations with payload?
    12. Why don't navigation properties raise the PropertyChanged event?
    13. Is there a way to access navigation properties that point to deleted objects within the SavingChanges event or SaveChanges virtual method?
  6. Object customization
    1. How do I write custom logic behind a "getter" or "setter"?
    2. Is it possible to write logic that distinguishes between user code calls to the data class and framework materialization of the class?
    3. How do I execute custom code on a SaveChanges call?
    4. How do I write business logic that validates interactions between multiple properties on an entity?
  7. Stored Procedure and Functions
    1. Can stored procedures return polymorphic results?
    2. How can I use stored procedures that only return simple types?
    3. Does the Entity Framework support the ability to have a single stored procedure that returns multiple result sets?
    4. How do I execute a query using a stored procedure with out-parameters?
    5. How do I call a stored procedure when using the ExecuteStoreCommand method?
    6. Function import for stored procedures with no results uses the ExecuteFunction overload that returns an int to report affected rows. Why does the function return -1 even though I know the rows were affected?
    7. How do I define custom functions (also called user-defined functions or model-defined functions or MDFs) in the conceptual model?
    8. Is it possible to call model-defined functions in LINQ queries?
  8. Code Generations and Customization
    1. How can I add custom attributes to my generated classes? What is the extensibility story in the Entity Framework for more advanced code generation scenarios
    2. Is there any way to use public, easily modifiable templates for EF code generation
  9.  Architectural Discussions
    1. Does the Entity Framework support entity objects being responsible to save changes themselves (rather than a central Save method on object context)?
    2. Does the Entity Framework have support for "Persistence Ignorance"? What is Persistence Ignorance? What is POCO? What is IPOCO?
    3. Should I use my EF entities as my business/domain objects or should I have separate classes for my persistence layer and my business layer?
  10. Object Context 
    1. Is it recommended to share one global ObjectContext instance across my application? What should be the lifetime of the ObjectContext?
    2. What is the recommendation for running a multithreaded application on the Entity Framework? Is the Entity Framework thread-safe?
    3. Does the provider connection stay open for the entire lifetime of the Object Context? When is the provider connection opened/closed?
    4. Do I need to explicitly call Dispose() on the ObjectContext object after use?
    5. What is the ObjectContext.Detach() method used for?
  11. Connection and Transaction Management 
    1. Can the container name and the connection string name be different?
    2. How can I create an ObjectContext using a database connection that has already been created?
    3. How are connection strings managed in the Entity Framework? How can I create a connection string at run time?
    4. Can I access the underlying database connection given an EntityConnection?
    5. What is the recommended way to manage transactions and connections with the Entity Framework?
    6. How do I set IsolationLevel/Lock Hints on single queries? Is it possible to set `NOLOCK` on a query?
    7. How do I avoid promotion of a transaction to a DTC?
  12. Querying Data
    1. I want to retrieve an object from ObjectContext without going to the database server. How can I execute queries locally rather than at the database?
    2. How can I see the T-SQL that is generated when I execute my queries?
    3. How do I use pre-compiled queries?
    4. How do I specify merge options on queries?
    5. Is lazy loading on by default?
    6. Can anonymous types participate in change tracking or updates?
    7. How do I retrieve a single entity?
    8. Is the data filtered on the database server or on the client?
    9. What are the different ways and considerations for loading related objects? Will using Load rather than Include improve performance?
    10. How does Include work with multiple levels of branches?
    11. Where in the query should Include be placed? How do I add Include on top of a LINQ expression?
    12. How do I dynamically build a general-purpose query for the Entity Framework?
    13. When working with Entity SQL, it is strongly recommended to use parameterized queries with ObjectParameters or EntityParameters to avoid SQL injection attacks. What about injection attacks in LINQ to Entities queries? How do I create parameterized LINQ queries?
    14. Does Entity Framework 4 support projections into EntityType classes?
    15. Where can I find information about using the Defining Query element within the SSDL of the Entity Framework, advantages of using it, and scenarios where it would be helpful?
    16. Can I use "Contains" with EF LINQ queries? How do I do something like the SQL "IN" clause?
  13. Serialization and web Services 
    1. Is Entity Key serializable?
    2. Is it possible to serialize a graph of related entities? Why am I getting only one entity at a time when I do XML serialization
    3. Is it possible to serialize the ObjectContext?
    4. What about WCF Data Services?
    5. Does ApplyCurrentValues/ApplyOriginalValues (ApplyPropertyChanges in EF 3.5 SP1) affect EntityReference properties? How do I merge a modified graph of entities back with my ObjectContext
    6. What are some considerations for choosing between self-tracking entities and WCF vs. WCF Data Services?
  14.  Data Binding 
    1. Do ObjectQuery and EntityCollection support databinding for WinForms / WPF? Where has the "ToBindingList" method gone?
  15. Concurrency
    1. How to handle concurrency in EF. 
  16. Miscellaneous
    1. Can I delete data that has not been queried from the database?
    2. My database isn't being updated, but no errors occurred in my application.
    3. How do I trace the commands that are executed against the data source?
    4. Is there TVF (table-valued function) support?
    5. Is there a way to write LINQ or Entity SQL statements that would be translated into set-based CUD operations without bringing the affected entities into memory (SQL DML statements)?
    6. What is the recommended way to use full-text search (FTS) queries with the Entity Framework?
    7. Does the Entity Framework support spatial data types?
    8. Does the Entity Framework support UDTs?
    9. Does Entity Framework 4 support DateTime functions like DayOfWeek?
    10. Is the POCO template part of Visual Studio?
    11. Is code-first part of the Entity Framework 4?
    12. Does the current version of the Entity Framework have "magic columns" or mapping/metadata conventions based on column names?
    13. What are some MVC with Entity Framework resources/samples?
  17. Performances 
    1. How to improve performance of enitty framework
    2. Hot to turn off/on lazy loading defaults

  1. http://social.technet.microsoft.com/wiki/contents/articles/3737.entity-framework-faq.aspx