Entity Framework Flashcards
What are the advantages of using EF over raw SQL?
It gives developers the ability to write T-SQL “like” syntax within a C# or other .NET environment.
What is DbSet in Entity Framework?
A DbSet represents the collection of all entities on the context, or that can be queried from the database of a given type.
What is a connection string used for - what information does it contain?
It’s an expression that contains the parameters required for the applications to connect a database server.
In the context of Entity Framework, what does scaffolding mean?
Scaffolding a database produces an Entity Framework model from an existing database.
What does the DbContext class contain?
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 are 1 to many relationships represented in the code model?
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.
What is the using keyword used for?
It defines a scope at the end of which an object will be disposed.
What is meant by a partial class and why is it useful?
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.
What are EF Migrations?
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.
What is the difference between the OO and relational approach?
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.