"You Must Master Entity Framework 6.x and Core 2.0" book published

foreword

I have written about 200 blogs so far. Readers who have read my blog should probably know that each of my blogs follows a consistent routine. From the preface to the topic and finally to the conclusion, this article is still the same routine as before, but it is not Introducing technology can also be said to introduce technology, but it is to introduce the technology in the book and my attitude towards writing. As a publicity for this book, the book will be published in the near future, and a purchase link will be released on the blog bulletin board at that time.

Original intention of writing

Before, an editor from a publishing house asked me to write a book. I looked at it and didn’t reply. Of course, it was nothing. The most important thing was that I felt that my qualifications were still inexperienced. Writing a book was very different from writing a blog. Blogs can be a little casual in words, but writing a book needs to be rigorous and concise in expression. Why did I write it later? I saw that the blog I wrote is the most EF. I remember when I first learned EF. , I also deliberately searched for relevant Chinese books as reference materials, but there were almost none. Later, I could only read the blogs of the seniors in the garden and the articles of foreigners to learn, and finally I wrote a part of it. Considering a complete EF series, at this time I thought if I could write a book on EF 6.x and EF Core 2.0? As a reference material for systematic study of EF 6.x and EF Core 2.0, it would be great if it can help beginners and those who want to go further. The book allows you to regain the correct understanding of EF and EF Core.

writing attitude

It took more than half a year from selecting the topic to writing the book. I was a little faster when I wrote the EF chapter, because I wrote it before, but it took a little time to read the document when EF updated a little content in the process. So relatively speaking, I am relatively proficient. When it comes to the EF Core chapter, the pace has slowed down a lot. Although I have written it, it is not deep enough, so it is equivalent to writing this book. I learned EF and EF Core from scratch and explored some in-depth. well known secret. I started reviewing the manuscript soon after writing it, and then the editor summarized the problems and handed it over to me to revise. At the same time, I also took responsibility for myself and the readers to correct the errors in the document seriously, and did not dare to slack off. Modified the problematic places and added some content, all of which were sent to the editor in the early morning ([cover face]), and I want to apologize to the editor here. The following is a detailed record of me from the beginning of writing to the official publication of the book.

Entity Framework 6.x and Core 2.0 you must master

The title of the book is like the title of the blog. You can also think of this book as Entity Framework 6.x and Core 2.0 that you don't know about. For example, do you know how EF 6.0 creates indexes? For example, do you know how to properly update data in EF 6.x? For example, do you know that in EF Core, it is not easy to use Include to perform starvation loading through lambda expressions? For example, do you know how to perform starvation loading through the Find or FindAsync methods in EF Core? For example, do you know what the essence of the EF Core context instance pool is? There are too many such questions, this book will take you to find out. This book is aimed at both basic and advanced learners. Whether you are self-studying or using EF 6.x or EF Core 2.0 in your projects, this book may be helpful to you.

Recommended thanks

I have only seen Brother Zhang Shanyou, and I have never met with other bigwigs. I don’t know if I can get the approval of the bigwigs. I went to the bigwigs to write a recommendation with an uneasy mood. I am here, I would like to express my gratitude, thank you Dudu boss, He Zhenxi, Zhang Shanyou, Zhao Pei (good friend), Zou Qiongjun, thank you for taking the time out of your busy schedule to recommend this book, thank you endorsement and support for this book. Here is an extra small advertisement: Brother He Zhenxi is now a member of the .NET Core China project, developing the application framework under the .NET Core platform by himself (https://github.com/dotnetcore/Util), thanks Brother He Zhenxi's contribution to .NET Core is also looking forward to the participation of people with lofty ideals.

writing directory

Part One 1
Chapter 1 7
EntityFramework History 7
1.1 EntityFramework Version Introduction 7
1.2 EntityFramework Domain Modeling 9
1.2.1 Code First 9
1.2.2 Model First 10
1.2.3 Database First 10
1.3 Using EntityFramework Code First 6.x or Reasons for Core 2.0 10
1.4 Summary 11
Chapter 2 12
Database table creation and migration 12
2.1 Database connection and initialization strategy 12
2.1.1 Database connection 12
2.1.2 Database initialization strategy 15
2.2 Conventions 17
2.2.1 Type discovery 17
2.2.2 Primary Key Conventions 17
2.2.3 Relational Conventions 19
2.2.4 Complex Type Conventions 20
2.2.5 Custom Conventions 21
2.3 Code-based Configuration Settings 29
2.4 Configuration Attribute Mapping and Relation Mapping 32
2.4.1 Attribute Mapping 32
2.4 .2 Relationship Mapping 50
2.4.3 Privatization Attribute Mapping 67
2.5 Inheritance Mapping Strategy 69
2.5.1 Table per Hierarchy (TPH) 70
2.5.2 Table per Type (TPT) 70
2.5.3 Table per Concrete class (TPC) 73
2.5.4 Entity Splitting 77
2.5.5 Table Splitting 80
2.6 Code Migration 82
2.6.1 Migration Commands 82
2.6.2 The Nature of Migration 91
Chapter 3 102
Entity State and Data Operations 102
3.1 Entity State 102
3.2 Data Operations 105
3.2.1 Data Queries 105
3.2.2 Data Storage 124
3.2.3 Automatically Generated Stored Procedures 135
3.3 Avoiding Traps
3.3.1 Navigation property query
3.3.2 Paging query
3.3.3 Semantic nullable
3.3.4 Table-valued function
3.3.5 Date operation
3.4 Basics actual combat 138
3.4.1 Complex properties stored as JSON database table column 138 Part
II 153
Chapter 4 155
Context Management and Change Tracking Principles 155
4.1 Context Lifecycle Management 155
4.1.1 Basic Pattern Traceability 155
4.1.2 Lifecycle Traceability 157
4.1.3 Evolutionary Pattern Tracking 160
4.2 Change Tracking Principles 163
4.2.1 Snapshot based Change Tracking 163
4.2.2 Notification based Change Tracking with Proxies 165
Chapter 5 175
Change Tracking Principles and Log Management 175
5.1 The Principle of DetectChanges 175
5.1.1 The Purpose of DetectChanges 175
5.1.2 When to Call the DetectChanges Method 177
5.1.3 Turn Off Automatically Calling the DetectChanges Method 180
5.1.4 Forgotten Binary Properties and Complex Types 182
5.2 Logging 186
5.2.1 ToString Printing 211
5.3 Transactions
_ _ _ _ 215 5.4 Connection Resiliency 240 Chapter 6 246 Concurrency Conflicts 246 6.1 Beginner Parsing 246 6.2 Intermediate Parsing 252 6.2.1 Client Wins 253










6.2.2 Database Wins 254
6.2.3 Client and Database Merge Wins 255
6.3 Advanced Parsing 256
6.3.1 Simple Retry Strategy 257
6.3.2 Polly Retry Strategy 257
Chapter 7 262
Performance Optimization Practices 262
7.1 Optimization One: Preliminary Compile view 262
7.2 Optimization 2: Reduce the first interaction with the database code 266
7.3 Optimization 3: NGen install EntityFramework assembly 269
7.4 Optimization 4: AsNoTracking 271
7.5 Optimization 5: DbFunctions/SqlFunctions 271
7.6 Optimization 6: Cache 276
7.7 Optimization 7: Recompile Query 282
7.8 Optimization 8: Avoid 'N+1' Select query 287
7.9 Optimization 9: Add index 289
7.10 Optimization 10: Disable callback DetectChanges method 293
7.11 Optimization 11: Use asynchronous query 296
Chapter 8 297
EntityFramework 6.x combat 297
8.1 Generic Repository and a Unit of Work 297
8.2 Generic Repository Pattern and Dependency Injection 321
Part III 338
Chapter 9 340
Database Table Creation and Migration 340
9.1 Database Initialization Strategies 340
9.2 Configuring Property Mapping and Relationship Mapping 344
9.2.1 Property Mapping 345
9.2.2 Backing Fields 357
9.2.3 Alternate Keys 362
9.2.4. Shadow Property 363
9.2.5 Owned Entities 368
9.2.6 HasQueryFilter 369
9.2.7 Relational Mapping 371
9.2.8 Inheritance Mapping 393
9.3 Code Migration 398
9.3.1 Console Application Migration 398
9.3.2 Web Application Migration 400
9.3.3 Multiple Context Migration 413
9.3.4 Scaffolding Reverse Migration 417
Chapter 10 422
Data Manipulation and Initialization Data 422
10.1 Entity State 422
10.2 Data Manipulation 423
10.2.1 Data Query 423
10.2.2 Data Storage 446
10.3 Connectionless Entities 452
10.4 Initializing Data 455 Title
IV 459
Chapter 11 461
Performance Optimization Practices 461
11.1 AsNoTracking 461
11.2 EF.Functions.Like 463
11.3 Custom Scalar Functions 466
11.4 Explicitly Compiled Queries 470
11.5 Context Instance Pools 473
Chapter 12 479
Querying Entity Metadata and Model Data Validation 479
12.1 Querying Metadata 479
12.2 Built-in Model Validation 481
12.3 Third-Party Extended Model Validation 484
Chapter 13 488
How Context Instances Are Created 488
13.1 Explicitly Creating Context Instances 488
13.1.1 OnConfiguring with Constructors 488
13.1.2 Passing Connection String Parameters to Constructors 489
13.1.3 Using DbContextOptions without Dependency Injection 489
13.2 Dependency Injection Containers create context instances 490
13.2.1 DI with no-argument constructor 490
13.2.2 DI with DbContextOptions 491
13.3.3 Using generic DbContextOptions 491
13.3.4 Using AddDbContext/AddDbContextPool 492 Chapter
14 494
Implementing multi-tenancy 494
15 Chapter 504
Capturing Audit Data 504
Chapter 16 510
Change Tracking Strategy and Log Management 510
16.1 Change Tracking Strategy 510
16.1.1 INotifyPropertyChanged 511
16.1.2 INotifyPropertyChanging 514
16.2 Log Management 516
16.2.1 Adding Console Package Output 516
16.2.2 Customizing Log Output 517
Chapter 17 521
xUnit Unit Testing 521
17.1 Console Unit Testing 522
17.2 NET Core Web Applications Program Unit Testing 524
Chapter 18 527
Transactions and Concurrency Conflicts 527
18.1 Transactions 527
18.2 Concurrency Conflicts 533
18.2.1 Beginner Parsing 534
18.2.2 Intermediate Parsing 538
18.2.3 Advanced Parsing 543
Chapter 19 550
EntityFramework Core 2.1 To Be Released 550
19.1 New features achieve goal 550

Summarize 

This book is EF 6.x and EF Core 2.0 as I understand it, and there are also some personal thoughts of mine. If this book can help you, then the sense of accomplishment is like writing a blog. I look forward to this book. With your approval, I will, as always, share what I have gained with you.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325474208&siteId=291194637