Entity Framework Core Cookbook - Second Edition

Leverage the full potential of Entity Framework with this collection of powerful and easy-to-follow recipes

Entity Framework Core Cookbook - Second Edition

This ebook is included in a Mapt subscription
Ricardo Peres

Leverage the full potential of Entity Framework with this collection of powerful and easy-to-follow recipes
$39.99
$49.99
RRP $39.99
RRP $49.99
eBook
Print + eBook
Subscribe and access every Packt eBook & Video.
 
  • 4,000+ eBooks & Videos
  • 40+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781785883309
Paperback324 pages

Book Description

Entity Framework is a highly recommended Object Relation Mapping tool used to build complex systems. In order to survive in this growing market, the knowledge of a framework that helps provide easy access to databases, that is, Entity Framework has become a necessity. This book will provide .NET developers with this knowledge and guide them through working efficiently with data using Entity Framework Core.

You will start off by learning how to efficiently use Entity Framework in practical situations. You will gain a deep understanding of mapping properties and find out how to handle validation in Entity Framework. The book will then explain how to work with transactions and stored procedures along with improving Entity Framework using query libraries. Moving on, you will learn to improve complex query scenarios and implement transaction and concurrency control. You will then be taught to improve and develop Entity Framework in complex business scenarios. With the concluding chapter on performance and scalability, this book will get you ready to use Entity Framework proficiently.

Table of Contents

Chapter 1: Improving Entity Framework in the Real World
Introduction
Improving Entity Framework by using a code-first approach
Unit testing and mocking
Creating databases from code
Creating mock database connections
Implementing the repository pattern
Implementing the unit of work pattern
Chapter 2: Mapping Entities
Introduction
Mapping non-public members
Mapping interfaces
Shadow properties
Creating one-to-one maps
Creating one-to-many maps
Creating many-to-many maps
Creating custom conventions
Using sequence key generators
Using GUIDs as keys
Implementing inheritance – Table per Class hierarchy
Chapter 3: Validation and Changes
Introduction
Validating simple properties
Validating the whole entity
Validating groups of entities
Intercepting saving changes
Intercepting property changes
Setting the state of an entity
Improving MVC UI with entity framework validation
Inserting, updating, and deleting entities with stored procedures
Updating the database from model changes
Dumping the SQL script for the database creation
Chapter 4: Transactions and Concurrency Control
Introduction
Using explicit transactions
Using transactions in custom SQL operations
Implementing optimistic concurrency in SQL Server
Implementing optimistic concurrency in a database-agnostic way
Chapter 5: Querying
Introduction
Executing client-side functions in LINQ queries
Mixing SQL with LINQ queries
Getting entities from the local cache
Creating filtered collections
Creating reusable queries
Querying shadow properties
Implementing the query object pattern
Using dynamic LINQ
Chapter 6: Advanced Scenarios
Introduction
Generating entities from the database
Implementing multitenancy
Strongly typed bulk operations
Handling soft deletes
Adding logging
Capturing the audit data
Retrieving entity metadata
Improving MVC applications
Hooking infrastructure services
Using other databases
Chapter 7: Performance and Scalability
Introduction
Improving the performance of queries
Testing and profiling queries
Using asynchronous operations
Eager loading
Using the cache

What You Will Learn

  • Master the technique of using sequence key generators
  • Validate groups of entities that are to be saved / updated
  • Improve MVC applications that cover applications developed using ASP.NET MVC Core 1
  • Retrieve database information (table, column names, and so on) for entities
  • Discover optimistic concurrency control and pessimistic concurrency control.
  • Implement Multilatency on the data side of things.
  • Enhance the performance and/or scalability of Entity Framework Core
  • Explore and overcome the pitfalls of Entity Framework Core

Authors

Table of Contents

Chapter 1: Improving Entity Framework in the Real World
Introduction
Improving Entity Framework by using a code-first approach
Unit testing and mocking
Creating databases from code
Creating mock database connections
Implementing the repository pattern
Implementing the unit of work pattern
Chapter 2: Mapping Entities
Introduction
Mapping non-public members
Mapping interfaces
Shadow properties
Creating one-to-one maps
Creating one-to-many maps
Creating many-to-many maps
Creating custom conventions
Using sequence key generators
Using GUIDs as keys
Implementing inheritance – Table per Class hierarchy
Chapter 3: Validation and Changes
Introduction
Validating simple properties
Validating the whole entity
Validating groups of entities
Intercepting saving changes
Intercepting property changes
Setting the state of an entity
Improving MVC UI with entity framework validation
Inserting, updating, and deleting entities with stored procedures
Updating the database from model changes
Dumping the SQL script for the database creation
Chapter 4: Transactions and Concurrency Control
Introduction
Using explicit transactions
Using transactions in custom SQL operations
Implementing optimistic concurrency in SQL Server
Implementing optimistic concurrency in a database-agnostic way
Chapter 5: Querying
Introduction
Executing client-side functions in LINQ queries
Mixing SQL with LINQ queries
Getting entities from the local cache
Creating filtered collections
Creating reusable queries
Querying shadow properties
Implementing the query object pattern
Using dynamic LINQ
Chapter 6: Advanced Scenarios
Introduction
Generating entities from the database
Implementing multitenancy
Strongly typed bulk operations
Handling soft deletes
Adding logging
Capturing the audit data
Retrieving entity metadata
Improving MVC applications
Hooking infrastructure services
Using other databases
Chapter 7: Performance and Scalability
Introduction
Improving the performance of queries
Testing and profiling queries
Using asynchronous operations
Eager loading
Using the cache

Book Details

ISBN 139781785883309
Paperback324 pages
Read More

Read More Reviews