• Stars
    star
    397
  • Rank 108,561 (Top 3 %)
  • Language
    C#
  • License
    MIT License
  • Created over 4 years ago
  • Updated almost 2 years ago

Reviews

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

Repository Details

Supporting repo to go with book "Entity Framework Core in Action", second edition

EfCoreInAction SecondEdition - part1 (master branch)

Welcome to the Git repo that is associated with the first six chapters in the book Entity Framework Core in Action (second edition). This book details how to use Entity Framework Core (EF Core) to develop database access code in .NET 5 applications.

The current release of this code is running on:

  • EF Core 5.1
  • ASP.NET Core 5.0 (You MUST have NET 5.0 installed)

Other branches are:

  • Part2, which covers part 2 of the book - chapters 7 to 11.
  • Part3, which covers part 3 of the book - chapters 12 to 17.

What you need to install to run the example applications

To run any of the code you need to.

  1. Install a development tool, either Visual Studio or Visual Studio Code (VS Code for short). If you are new to .NET Core development, then I recommend Visual Studio - here is a link on how to install Visual Studio.
  2. You need to install the NET 5 or above SDK. You can find this a Microsoft NET download - select the Build apps - SDK version.
    NOTE: If you installed the latest version of Visual Studio it should have installed NET 5 SDK for you. Use the console command dotnet --list-sdks to check what NET versions are installed.
  3. You need to install a SQL Server to run any applications and some of the unit tests. A SQL Server called localdb is installed when you install Visual Studio on Windows by choosing the "Data storage and processing" feature (VS Code and Visual Studio on Mac needs more work).
  4. Clone this repo to your local computer. See Visual Studio tutorial called Open a project from a repo.

What can you run in this branch?

I have placed all the code relating to part 1 of the book, which covers the first six chapters. The main projects you can run are:

  • MyFirstEfCoreApp, which is the console application found in chapter 1
  • BookApp, which is the ASP.NET Core application that I cover in chapters 2 to 6. Best to mark that project as your Startup Project

Once you have installed your chosen development tool, then you can run either of these applications - both are designed to create and seed any database that they use.

How to find and run the unit tests

Every chapter has a set of unit tests to check that what I say in the book is correct. These unit tests are also useful to you the reader as sometimes seeing the actual code is a quicker way to see how something works.

How to find the unit tests

The unit tests are all in the Test project and uses xUnit. The unit tests are all in the UnitTests directory split into directories based on what they are testing - for instance, the UnitTests/TestDataLayer directory have all the tests that work directly with the database.

How to run the unit tests

If you are using Visual Studio, then its Test feature via the Test button found on the top toolbar - see Microsoft's VS unit test docs.

If you are using , then you use it Test feature, via the tests icon (looks like a scientific flask). VS Code needs some setting up to work with C#, but once thats done then this repo has the necessary .vscode files set up to run the unit tests - see VS Code C# docs for more on using VS Code C#.

Many of the tests use SQLite in-memory databases which just work. But some tests use SQL Server. If you are using Visual Studio on Windows you should install the the "Data storage and processing" feature. This should give you a SQL Server called localdb, which the standard unit tests use. If you need to change the SQL Server name etc. then you should change the connection string called UnitTestConnection in the appsettings.json file in the Test project.

If you are using Visual Studio on Mac, or VS Code on Mac or linux, then you need to install a SQL Server to allow the unit tests that need that type of database.

If you have problems with the code

If you are having problems with the application then please post an issue on the EfCoreInAction-SecondEdition issues page, with the stack trace or compile error and I will have a look and get back to you.

If you find an error in the book

If you find an error in the book, then please add a comment via Manning's LiveBook version of the book. Please make sure you say what section it is in as it's sometimes hard for me to link your comment to the section of the book.

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

EfCore.TestSupport

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

EfCoreInAction

Supporting code to go with the book "Entity Framework Core in Action"
340
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