Book Image

Code-First Development with Entity Framework

By : Sergey Barskiy
Book Image

Code-First Development with Entity Framework

By: Sergey Barskiy

Overview of this book

<p>Entity Framework Code-First enables developers to read and write data in a relational database system using C# or VB.NET. It is Microsoft's answer to demand for an ORM from .NET developers.</p> <p>This book will help you acquire the necessary skills to program your applications using Entity Framework. You will start with database configuration and learn how to write classes that define the database structure. You will see how LINQ can be used with Entity Framework to give you access to stored data. You will then learn how to use Entity Framework to persist information in a Relational Database Management System. You will also see how you can benefit from writing ORM-based .NET code. Finally, you will learn how Entity Framework can help you to solve database deployment problems using migrations.</p>
Table of Contents (15 chapters)
Code-First Development with Entity Framework
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Self-test questions


Q1. Which of the following is NOT a syntax supported by LINQ?

  1. Method.

  2. SQL.

  3. Query.

Q2. If you retrieve an entity via LINQ from a database, make changes to it and call SaveChanges, all properties are updated in the database, not only the changed ones, true or false?

Q3. In order to sort the data by multiple properties, you simply need to call OrderBy multiple times in LINQ that is using the method syntax, true or false?

Q4. How to add two filter conditions to a LINQ query with the query syntax?

  1. Use multiple Where calls.

  2. Use logical AND operator.

  3. Issue two queries.

Q5. You want to add multiple new entities to DbSet. How can you accomplish this?

  1. By calling the Add method and passing an instance of the class specified in the context property.

  2. By calling AddRange and pass an enumerable of the target entity type.

  3. By setting the state to Added using the context API on each new entity.

  4. All of the above.

Q6. If you want to create a new entity with some child entities, also known as object graph...