• Stars
    star
    340
  • Rank 124,317 (Top 3 %)
  • Language
  • License
    MIT License
  • Created over 7 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Supporting code to go with the book "Entity Framework Core in Action"

EfCoreInAction

Welcome to the Git repo that is associated with the book Entity Framework Core in Action published by Manning Publications. This book details how to use Entity Framework Core (EF Core) to develop database access code in .NET Core applications.

This Git repo contains all the code in the book, plus an example book selling site that I develop, and improve, in the book. All the code uses Microsoft's, open-source Entity Framework Core library for database access.

NOTE: Code uses .NET Core 2.0, with a few branches converted to .NET Core 2.1
See Where's the code.

To run the changed Git repo code you need to:

  1. Install .NET Core 2.0 SDK – go to https://www.microsoft.com/net/download/core and select the correct SDK for your system
  2. I recommend updating to Visual Studio 2017 15.3 or later as that has the new templates for ASP.NET Core 2.0.0. Or use Visual Studio code (the code is designed to work with either VS2017 or VSCode)

Where's the code!

This repo has a branch-per-chapter, and sometime and branch-per-section, approach so if you are looking at the master branch then you won't see any code! Just click the Branches on the site and you will find all the branches I have created so far.

Map of the branches

The branches mainly inherit from each other (shown as --> in the diagram) but a few are on there own, like master and Chapter01 (shown with spaces between them). The ones that are build for deployment to a web site are branches off the main stem (shown as higher offshoots). I did that because I built the normal code so you can run it locally without migrations.
Note: to fit the diagram in I shorten the real branch names and use Ch4 instead of Chapter04

Part 1 - Getting started

                                        Ch5Migrate
                                          /
master    Ch1    Ch2 --> Ch3 --> Ch4 --> Ch5 -->

Part 2 - Entity Framework in depth

(ch5) --> Ch6 --> Ch7 --> Ch8 --> Ch9

Part 3 - Using Entity Framework in real-world applications

                                           Ch13-Part3
                                              /
                                        Ch13-Part2    Ch14MySql
                                            /         /
(ch9) --> Ch10 --> Ch11 --> Ch12 --> Ch13-Part1 --> Ch14  --> (Ch15) Note1

Note1: Chapter 15, on unit testing has its own Git repo https://github.com/JonPSmith/EfCore.TestSupport and a NuGet package called EfCore.TestSupport.

NET Core 2.1 examples

I wanted to compare the performance of EF Core 2.0 and EF Core 2.1, so I created a few new branches. Here is the list:

  • Chapter05-NetCore21
  • Chapter13-Part1-NetCore21
  • Chapter13-Part2-NetCore21

NET Core 3 examples

To support EF Core 3 I created new branches. They are there to help you if you want to work with EF Core 3. I also used the Chapter13-Part3-NetCore3 branch to find all the changes between EF Core 2 and EF Core 3 (the unit tests are very helpful for that). Here is the list:

  • Chapter01-NetCore3
  • Chapter05-NetCore3
  • Chapter13-Part3-NetCore3

Live example book selling site

You can find a live verison of the example books selling site. This provides an online example of the site to look at. You can't edit the data on the live site for obvious reasons, but you can if you clone the git this Git repo and run the example application locally. You can 'buy a book' though on the live site, and even see your old 'purchases'.

The Logs navigation button will show you the SQL code that EF Core used to implement the last command you used.

Diagram of site

Note: The admin button is missing on the live site.

Database naming conventions

Because the database structure can change in each branch I use a system of building the database name using the branch name from a file which is written by a small gulpfile that is run by Visual Studio # on every build.

Also I use xUnit unit tests which run in parallel, so I cannot use one database for all the tests, as they would all be changing the database at one time. I therefore use another system to append the test class name, and sometimes the method that ran. This is all explained in chapter 11, but I wanted to warn you you will get lots of databases if you run the unit tests.

If you get fed up with all databases there is a unit test in test/UnitCommands/DeleteAllUnitTestDatabases that will delete all the unit test databases in the branch you are in.

Licence

MIT

Other links

My twitter handle is @thereformedprog.
My blog site is at http://www.thereformedprogrammer.net/ where you will find articles on EF 6.x and some on EF Core.

Happy coding!

More Repositories

1

AuthPermissions.AspNetCore

This library provides extra authorization and multi-tenant features to an ASP.NET Core application.
C#
774
star
2

EfCore.GenericServices

A library to help you quickly code CRUD accesses for a web/mobile/desktop application using EF Core.
C#
598
star
3

EfCoreinAction-SecondEdition

Supporting repo to go with book "Entity Framework Core in Action", second edition
C#
397
star
4

EfCore.TestSupport

Tools for helping in unit testing applications that use Entity Framework Core
C#
353
star
5

PermissionAccessControl2

Version 2 of example application to go with articles on feature and data authorization
C#
276
star
6

GenericServices

GenericServices helps with building a service/application layer in a .NET based application using EF6.x
C#
245
star
7

NetCore.AutoRegisterDi

Extension method to find/register classes in an assembly into the Microsoft DI provider
C#
234
star
8

PermissionAccessControl

Example code for Authorization articles
C#
224
star
9

EfCore.GenericBizRunner

Library to run business logic when using Entity Framework Core for database accesses
C#
216
star
10

AspNetReactSamples

Template/Sample ASP.NET projects to develop/build/test React.js apps
JavaScript
174
star
11

EfCore.SoftDeleteServices

Services to provide simple soft delete and cascade soft delete in EF Core
C#
114
star
12

EfCore.SchemaCompare

Library to compare EF Core's Model of the database against a database's schema.
C#
106
star
13

Net.DistributedFileStoreCache

NET distributed cache using a json file as the shared resourse with very fast Get
C#
96
star
14

SampleMvcWebApp

A Sample MVC5 web application showing the use of GenericServices for CRUD operations
C#
75
star
15

EfCore.GenericEventRunner

A library to allow developer use events to update their database via Entity Framework Core (EF Core)
C#
67
star
16

EfCoreSqlAndCosmos

Example CQRS application using Cosmos DB with EF Core
C#
66
star
17

BookApp.All

Example of applying an modular monolith approach to building apps. This version contains the whole app in one solution
C#
50
star
18

EfCore.GenericServices.AspNetCore

Converts EFCore.GenericServices and EfCore.GenericBizRunner statuses to ASP.NET Core formats
C#
49
star
19

EfSchemaCompare

EfSchemaCompare.EF6 allows you to compare Entity Framework's database modal with an actual SQL database.
C#
44
star
20

RunStartupMethodsSequentially

A .NET library that runs methods within a locked state on startup. This is useful if you want to migrate or seed a database on an web application that has multiple instances.
C#
32
star
21

EfCore.SoftDeleteServices-Old

Services to provide simple soft delete and cascade soft delete in EF Core
C#
29
star
22

GenericServices.StatusGeneric

Implements the "return a status" pattern - useful for code that can return errors
C#
28
star
23

SampleMvcWebAppComplex

A more complex MVC application showing the use of GenericServices with the AdventureWorksLT2012 database.
C#
26
star
24

Net.LocalizeMessagesAndErrors

This library provides extra code to make it easier to support in different languages in your .NET application
C#
18
star
25

MvcUsingBower

Applying Visual Studio's Bower/Grunt tools to a ASP.NET MVC application. See
JavaScript
16
star
26

PermissionsOnlyApp

C#
15
star
27

DDDExampleCode

Example code to go with my talk and article on DDD
C#
13
star
28

MultiProgPackTool

https://www.thereformedprogrammer.net/evolving-modular-monoliths-2-breaking-up-your-app-into-multiple-solutions/#how-to-create-a-nuget-packages
C#
9
star
29

SimpleMessageBroker

C#
5
star
30

Ef6BookApp

C#
4
star
31

AspNetCore.MultipleHostedService

C#
3
star
32

AuthP.CustomDatabaseExamples

C#
2
star
33

BookApp.Books

Part of the evolving Modular Monalith
C#
2
star
34

TryAspNetCoreMigrate

C#
2
star
35

BookApp.Main

C#
2
star
36

TestSupportSchema

C#
1
star