Entity Framework Core in Action, Second Edition
eBook - ePub

Entity Framework Core in Action, Second Edition

Jon P Smith

Compartir libro
  1. 624 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Entity Framework Core in Action, Second Edition

Jon P Smith

Detalles del libro
Vista previa del libro
Índice
Citas

Información del libro

"The most comprehensive reference for EF Core that does—or ever will—exist." - Stephen Byrne, Intel Corporation Entity Framework Core in Action, Second Edition teaches you to write flawless database interactions for.NET applications. Summary
Entity Framework Core in Action, Second Edition is an in-depth guide to reading and writing databases with EF Core. Revised from the bestselling original edition, it's filled with over 100 diagrams, code snippets, and examples—including building and scaling your own bookselling web application. Learn from author Jon Smith's extensive experience working with EF Core in production, as you discover time-saving patterns and best practices for security, performance tuning, and unit testing. All of the book's code is available on GitHub. Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. About the technology
Entity Framework radically simplifies data access in.NET applications. This easy-to-use object-relational mapper (ORM) lets you write database code in pure C#. It automatically maps classes to database tables and enables queries with standard LINQ commands. It even generates SQL, so you don't have to! About the book
Entity Framework Core in Action, Second Edition teaches you to write flawless database interactions for.NET applications. Following relevant examples from author Jon Smith's extensive experience, you'll progress quickly from EF basics to advanced techniques. In addition to the latest EF features, this book addresses performance, security, refactoring, and unit testing. This updated edition also contains new material on NoSQL databases. What's inside Configure EF to define every table and column
Update your schema as your app grows
Integrating EF with existing C# application
Write and test business logic for database access
Applying a Domain-Driven Design to EF Core
Getting the best performance out of EF Core About the reader
For.NET developers familiar with relational databases. About the author
Jon P. Smith is a freelance software developer and architect with a special focus on.NET and Azure. Table of Contents PART 1
1 Introduction to Entity Framework Core
2 Querying the database
3 Changing the database content
4 Using EF Core in business logic
5 Using EF Core in ASP.NET Core web applications
6 Tips and techniques for reading and writing with EF Core
PART 2
7 Configuring nonrelational properties
8 Configuring relationships
9 Handling database migrations
10 Configuring advanced features and handling concurrency conflicts
11 Going deeper into the DbContext
PART 3
12 Using entity events to solve business problems
13 Domain-Driven Design and other architectural approaches
14 EF Core performance tuning
15 Master class on performance-tuning database queries
16 Cosmos DB, CQRS, and other database types
17 Unit testing EF Core applications

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Entity Framework Core in Action, Second Edition un PDF/ePUB en línea?
Sí, puedes acceder a Entity Framework Core in Action, Second Edition de Jon P Smith en formato PDF o ePUB, así como a otros libros populares de Computer Science y Programming Languages. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Editorial
Manning
Año
2021
ISBN
9781638351313

Part 1 Getting started

Data is everywhere, growing by petabytes per year, and a lot of it is stored in databases. Millions of applications are also out there—at the beginning of 2021, there were 1.2 billion websites—and most of them need to access data in databases. And I haven’t started on the Internet of Things yet. So it shouldn’t be a surprise that Gartner, a leading research and advisory company, says that global IT spending will reach $3.7 trillion in 2021 (http://mng.bz/gonl).
The good news for you is that your skills will be in demand. But the bad news is that the pressure to develop applications quickly is unrelenting. This book is about one tool that you can use to write database access code quickly: Microsoft’s Entity Framework Core (EF Core). EF Core provides an object-oriented way to access relational and nonrelational (NoSQL) databases in the .NET environment. The cool thing about EF Core and the other .NET Core libraries is that they can run on the Windows, Linux, and Apple platforms, and they’re fast.
In part 1, I get you into the code straightaway. In chapter 1, you’ll build a super-simple console application, and by the end of chapter 5, you’ll build a reasonably sophisticated web application that sells books. Chapters 2 and 3 explain the reading and writing of data to a relational database, respectively, and chapter 4 covers writing your business logic. In chapter 5, you’ll use Microsoft’s ASP.NET Core web framework to build the example book-selling site. Chapter 6 expands your knowledge of how EF Core works inside through a series of useful techniques for solving database problems, such as a quick way to copy data in the database.
You’ll have a lot of learning to do in part 1, even though I skip a few topics, mainly by relying on a lot of EF Core’s default settings. Nevertheless, part 1 should give you a good understanding of what EF Core can do, with later parts growing your knowledge with extra EF Core features, more details on how you can configure EF Core, and chapters devoted to specific areas such as performance tuning.

1 Introduction to Entity Framework Core

This chapter covers
  • Understanding the anatomy of an EF Core application
  • Accessing and updating a database with EF Core
  • Exploring a real-world EF Core application
  • Deciding whether to use EF Core in your application
Entity Framework Core, or EF Core, is a library that software developers can use to access databases. There are many ways to build such a library, but EF Core is designed as an object-relational mapper (O/RM). O/RMs work by mapping between two worlds: the relational database, with its own API, and the object-oriented software world of classes and software code. EF Core’s main strength is allowing software developers to write database access code quickly in a language that you may know better than SQL.
EF Core is multiplatform-capable: it can run on Windows, Linux, and Apple. It does this as part of the .NET Core initiative—hence the Core part of the EF Core name. .NET 5 covers the whole range of desktop, web, cloud, mobile, gaming, Internet of Things (IoT), and artificial intelligence (AI), but this book is focused on EF Core.
EF Core isn’t the first version of Entity Framework; an existing, non-Core, Entity Framework library is known as EF6.x. EF Core starts with years of experience built into it via feedback from these previous versions, 4 to 6.x. It has kept the same type of interface as EF6.x but has major changes underneath, such as the ability to handle nonrelational databases, which EF6.x wasn’t designed to do. I had used EF5 and EF6 in many applications before EF Core came along, which allowed me to see the significant improvements EF Core made over EF6.x in both features and performance.
This book is for software developers who are already using EF Core, as well as developers who’ve never used Entity Framework, and seasoned EF6.x developers who want to move over to EF Core. I do assume that you’re familiar with .NET development using C# and that you have at least some idea of what relational databases are. I don’t assume you know how to write Structured Query Language (SQL), the language used by a majority of relational databases, because EF Core can do most of that for you. But I do show the SQL that EF Core produces because it helps you understand what’s going on; using some of the EF Core advanced features requires you to have SQL knowledge, but the book provides plenty of diagrams to help you along the way.
tip If you don’t know a lot about SQL and want to learn more, I suggest the W3Schools online resource: https://www.w3schools.com/sql/sql_intro.asp. The SQL set of commands is vast, and EF Core queries use only a small subset (such as SELECT, WHERE, and INNER JOIN), so that resource is a good place to start.
This chapter introduces you to EF Core through the use of a small application that calls into the EF Core library. You’ll look under the hood to see how EF Core interprets software commands and accesses the database. Having an overview of what’s happening inside EF Core will help you as you read through the rest of the book.

1.1 What you’ll learn from this book

The book gives you an introduction to EF Core, starting with the basics and advancing to some more complex parts of EF Core. To get the best out of this book, you should be comfortable with developing applications using C#, including creating projects and loading NuGet packages. You will learn
  • The fundamentals of using EF Core to access a database
  • How to use EF Core in an ASP.NET Core web application
  • The many ways you can configure EF Core to work exactly as you need
  • Some of the deeper database features you might want to use
  • How to handle changes in the database layout as your application grows
  • How to improve the performance of your database code
  • Most important, how to make sure that your code is working correctly
Throughout the book I build simple but fully featured applications so that you can see EF Core working in real situations. All these applications are available via the example repo, which also includes lots of tips and techniques I have picked up while working as a contract developer and on my own projects.

1.2 My “lightbulb moment” with Entity Framework

Before we get into the nitty-gritty, let me tell you about one defining moment I had when using Entity Framework that put me on the road to embracing EF. It was my wife who got me back into programming after a 21-year gap (that’s a story in itself!).
My wife, Dr. Honora Smith, is a lecturer in mathematics at the University of Southampton, who specializes in the modeling of healthcare systems, especially focusing on where to locate health facilities. I had worked with her to build several applications to do geographic modeling and visualization for the UK National Health Service and worked for South Africa on optimizing HIV/AIDS testing.
At the start of 2013, I decided to build a web application specifically for healthcare modeling. I used ASP.NET MVC4 and EF5, which had just come out and supported SQL spatial types that handle geographic data. The project went okay, but it was hard work. I knew that the frontend was going to be hard; it was a single-page application using Backbone.js, but I was surprised at how long it took me to do the server-side work.
I applied good software practices and made sure that the database and business logic were matched to the problem space—that of modeling and optimizing the location of health facilities. That was fine, but I spent an inordinate amount of time writ...

Índice