Entity Framework Flashcards

1
Q

What are the advantages of using EF over raw SQL?

A

It gives developers the ability to write T-SQL “like” syntax within a C# or other .NET environment.

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

What is DbSet in Entity Framework?

A

A DbSet represents the collection of all entities on the context, or that can be queried from the database of a given type.

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

What is a connection string used for - what information does it contain?

A

It’s an expression that contains the parameters required for the applications to connect a database server.

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

In the context of Entity Framework, what does scaffolding mean?

A

Scaffolding a database produces an Entity Framework model from an existing database.

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

What does the DbContext class contain?

A

It contains DbSets which are a representation of the tables in the database. It can be seen as the entry access to the database itself.

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

How are 1 to many relationships represented in the code model?

A

2 ways:

Using the reference navigation property, where the class(table) references another class in its code body

Using the collection property, similar to the reference, except you reference the whole class in the code body.

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

What is the using keyword used for?

A

It defines a scope at the end of which an object will be disposed.

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

What is meant by a partial class and why is it useful?

A

Partial classes are portions of a class that the complier can combine to form a complete class.

It can allow a class’s definition to span across multiple files. This can allow better maintainability and separation of your code.

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

What are EF Migrations?

A

It provides a way to incrementally update the database schema to keep it in sync with the application’s data model while preserving existing data in the database.

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

What is the difference between the OO and relational approach?

A

The main difference between object oriented and object relational database is the that OO is a database that represents data in the form of objects like in OOP while relational database is a database that is based on the relational model and object-oriented database model.

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