Introduction to Entity Framework Flashcards

1
Q

What is Object-Relational-Mapping?

A

The idea of being able to write queries like
this, as well as much more complicated ones, using your preferred object-oriented programming language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the advantages of using ORM?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the disadvantages of ORM?

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Entity Framework?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the Entity Data Model?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the Storage Model?

A

Represents the underlying database schema including tables, views, stored procedures, relationships, and keys. Reflecting actual database designs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are mappings?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the Context Class in Entity Framework?

A

Represents a session with the underlying database, allowing for CRUD operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the Model-First approach>

A

Create entities, relationships, and inheritance hierarchies on a visual designer in Visual Studio. Generate entities, context class, and database script from the visual model.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an entity in Entity Framework?

A

A class that maps to a database table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does Entity Framework map an entity to a database table?

A

By including the entity as a DbSet<TEntity> type property in the DbContext class</TEntity>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the components of the Entity Data Model (EDM)?

A

Conceptual model, storage model, and mappings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In EF Core, which approach is mainly targeted and why?

A

Code-First, because it allows creating a database and tables using migration based on domain classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the two types of entities in Entity Framework?

A

POCO Entities and Dynamic Proxy Entities.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a POCO (Plain Old CLR Object) Entity?

A

A POCO entity is a class that doesn’t depend on any framework-specific base class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is Dynamic Proxy Entity?

A

Dynamic Proxy is a runtime proxy class which wraps POCO entity.

17
Q

What are the three approaches with Entity Framework?

A

Database-First, Code-First, Model-First

18
Q

What is the Database-First approach?

A

In the database-first development approach, you generate the context
and entities for the existing database using EDM wizard integrated in
Visual Studio.

19
Q

What is the Code-First approach?

A

Use this approach when you do not have an existing database for your
application.

In the code-first approach, you start writing your entities (domain
classes) and context class first and then create the database from
these classes using migration commands.

20
Q

What is the Model-First Approach?

A

Use this approach when you do not have an existing database for your
application.

In the code-first approach, you start writing your entities (domain
classes) and context class first and then create the database from
these classes using migration commands.

21
Q

What two approaches does EF Core support?

A

Code-First and Database-First.