Introduction to Entity Framework Flashcards
What is Object-Relational-Mapping?
The idea of being able to write queries like
this, as well as much more complicated ones, using your preferred object-oriented programming language
What are the advantages of using ORM?
- Language Fluency
- Abstracts Database Systems
- Advanced Features: Many ORMs come with built-in features such as:
Support for transactions
Connection pooling
Migrations
Seeds
Streams - Performance
What are the disadvantages of ORM?
- Performance Overhead: Expert SQL developers may write more performant queries than those generated by an ORM.
- Learning Curve: There is a learning curve associated with mastering any given ORM.
- Initial Configuration: Setting up an ORM can be complex and time-consuming.
- Abstraction Drawbacks: Over-reliance on ORM can lead to a lack of understanding of underlying database mechanics and SQL.
What is Entity Framework?
Entity Framework is an object-relational
mapper (ORM) that enables .NET developers to work with a database using .NET objects.
It eliminates the need for most of the
data-access code that developers usually need to write.
What is the Entity Data Model?
Contains model classes and their relationships, independent of the database table design. Representing the entities and relationships in a way that is familiar to object-oriented developers.
What is the Storage Model?
Represents the underlying database schema including tables, views, stored procedures, relationships, and keys. Reflecting actual database designs.
What are mappings?
Information about how the conceptual model is mapped to the storage model.
Enables EF to perform CRUD operations by transforming LINQ queries into SQL commands and converting database results back into entity objects.
What is the Context Class in Entity Framework?
Represents a session with the underlying database, allowing for CRUD operations.
What is the Model-First approach>
Create entities, relationships, and inheritance hierarchies on a visual designer in Visual Studio. Generate entities, context class, and database script from the visual model.
What is an entity in Entity Framework?
A class that maps to a database table
How does Entity Framework map an entity to a database table?
By including the entity as a DbSet<TEntity> type property in the DbContext class</TEntity>
What are the components of the Entity Data Model (EDM)?
Conceptual model, storage model, and mappings.
In EF Core, which approach is mainly targeted and why?
Code-First, because it allows creating a database and tables using migration based on domain classes.
What are the two types of entities in Entity Framework?
POCO Entities and Dynamic Proxy Entities.
What is a POCO (Plain Old CLR Object) Entity?
A POCO entity is a class that doesn’t depend on any framework-specific base class.