Brian L. Gorman
Practical Entity Framework Core 6
Database Access for Enterprise Applications
2nd ed.
Logo of the publisher
Brian L. Gorman
Jesup, IA, USA
ISBN 978-1-4842-7300-5 e-ISBN 978-1-4842-7301-2
https://doi.org/10.1007/978-1-4842-7301-2
Brian L. Gorman 2022
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Apress imprint is published by the registered company APress Media, LLC part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.
This book is dedicated to my wife Cassie and my children Kiera, Karson, Kreighton, and baby K who have all made many sacrifices to give me the space and time to write, as well as for your daily, unceasing love, grace, patience, and encouragement.
This book is further dedicated to you, dear reader. Thank you for allowing me to be part of your journey to greatness.
Introduction
Entity Framework is the object-relational mapper (ORM) of choice for a majority of enterprise application development teams which are leveraging Microsoft .Net technologies. Through the years, EF has gone through a number of changes, and the move into the .Net Core world has seen EF become more performant and more user-friendly.
As this book begins, well take a look at the state of things as they are and the state of things to come. Well begin the real work by touching on the two different approaches to working with a database using EFCore: database first and code first. After the first three chapters, we settle in on the code-first approach with EFCore and approach practical, real-world scenarios to help you and your team develop robust and rugged data solutions while learning the fundamental concepts necessary to effectively work with EFCore.
The great news is that no matter what approach to the database or version of EF you are using, with just a few minor exceptions, things will generally work in a similar fashion, so all of the information in this book is relevant to anyone working with Entity Framework.
Who this book is for
Practical Entity Framework is written for anyone that is new to Entity Framework or is still learning and wants to become much better with Entity Framework.
If you are already an expert or a well-established developer with a few years of EF under your belt, this book will likely not have a lot of new information for you, but there may be a couple of concepts that you would still benefit from reviewing.
Overall, the book is designed as a practical approach which means that there is a lot of hands-on work to step through the moving pieces that are necessary to understand and work with EFCore, as well as how to approach architecting SOLID solutions around EFCore.
The practical nature of each activity will give you many examples and cover a lot of the basic and advanced topics you will likely encounter in real-world applications.
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484273005. For more detailed information, please visit http://www.apress.com/source-code.
Acknowledgments
I would not have been able to write this book if it were not for a number of people who have both influenced and helped me throughout my career, as well as the multitudes of grace and support that I have received from my family throughout this process.
Id like to begin by thanking Andr van Meulebrouck for his excellent work as a technical reviewer and editor. Andrs thoughts and comments throughout the process have greatly helped to shape this book over the first and second editions. Also, his incredible patience with working through a couple of bugs with the solution files has been an invaluable resource to help ensure the resources work and the directions are easy to follow. An extra special thanks to Andr as well for consistently putting up with my misuse of setup vs. set up (you would think Id be better at this by now).
Id also like to thank the many friends and acquaintances Ive made at various tech conferences in the past few years. Ive learned so much from all of you. There are a few that I must mention, however. First, Mike Cole, my peer and friend, thank you for introducing me to AutoMapper projections, and thanks for all your candid conversations around Entity Framework (EF) with me as I wrote this book. Thanks to Mitchel Sellers for your talk on Entity Framework that I got to see at Iowa Code Camp and again at our CVINETA meeting a couple of years ago, which focused on addressing the performance pitfalls that arise from misusing Language Integrated Query (LINQ).
Thank you to Apress and the team who have believed in me and have helped to make this book possible. Thanks to Jonathan Gennick and Jill Balzano for running the project, editing, and overseeing the entire schedule and process.
I would be remiss if I didnt also thank Dustin Behn, the leader of the Inspired Nation, and his life coaching and his Emergence program. Thank you for coaching me these past few years and for helping me get out of my own way to do things like this book.
Last, and most importantly, to my wife Cassie and our kids, to whom the book is also dedicated. Thank you for giving me the time and space to make this book happen and for continually checking on my progress by asking how many chapters I have done and how many I have left.
Table of Contents
Part I: Getting Started
Part II: Building the Data Solution
Part III: Enhancing the Data Solution
Part IV: Recipes for Success
About the Author
Brian L. Gorman
is a Microsoft Azure MVP, developer, computer science instructor, and trainer and has been working in .Net technologies as long as they have existed. He was originally MCSD certified in .Net 1 and re-certified with MCSA: Web Apps and MCSD: App Builder certifications in 2019. From 2019 to 2022, Brian has earned nine Azure certifications, including Azure and Data Fundamentals, Azure Administrator, Database Administrator, Security Engineer, and Developer Associate certifications, Azure Solutions Architect and DevOps Expert certifications, and an IoT Specialty certification.