All Projects → JeremyLikness → Blazorwasmefcoreexample

JeremyLikness / Blazorwasmefcoreexample

Licence: mit
Example of a Blazor WebAssembly project that uses Entity Framework Core on the server for data access.

Projects that are alternatives of or similar to Blazorwasmefcoreexample

Localization
🌏 Database Resource Localization for .NET Core with Entity Framework and In Memory Cache
Stars: ✭ 68 (-35.24%)
Mutual labels:  entity-framework, entity-framework-core
Entityframework.exceptions
Handle database errors easily when working with Entity Framework Core. Supports SQLServer, PostgreSQL, SQLite, Oracle and MySql
Stars: ✭ 266 (+153.33%)
Mutual labels:  entity-framework, entity-framework-core
EFCore.Cassandra
Entity Framework Core provider for Cassandra
Stars: ✭ 23 (-78.1%)
Mutual labels:  entity-framework, entity-framework-core
NETProvider
Firebird ADO.NET Data Provider
Stars: ✭ 113 (+7.62%)
Mutual labels:  entity-framework, entity-framework-core
Efcore.pg
Entity Framework Core provider for PostgreSQL
Stars: ✭ 838 (+698.1%)
Mutual labels:  entity-framework, entity-framework-core
Gridify
Easy and optimized way to apply Filtering, Sorting, and Pagination using text-based data.
Stars: ✭ 372 (+254.29%)
Mutual labels:  entity-framework, entity-framework-core
Efdesigner
Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
Stars: ✭ 256 (+143.81%)
Mutual labels:  entity-framework, entity-framework-core
BlazorEFCoreMultitenant
Examples of multitenancy using EF Core and Blazor.
Stars: ✭ 67 (-36.19%)
Mutual labels:  entity-framework, entity-framework-core
Sample Dotnet Core Cqrs Api
Sample .NET Core REST API CQRS implementation with raw SQL and DDD using Clean Architecture.
Stars: ✭ 1,273 (+1112.38%)
Mutual labels:  entity-framework, entity-framework-core
Efcorepowertools
Entity Framework Core Power Tools - reverse engineering, migrations and model visualization for EF Core
Stars: ✭ 774 (+637.14%)
Mutual labels:  entity-framework, entity-framework-core
.NET-Core-Learning-Journey
Some of the projects i made when starting to learn .NET Core
Stars: ✭ 37 (-64.76%)
Mutual labels:  entity-framework, entity-framework-core
Entityframework.commontools
Extensions, Auditing, Concurrency Checks, JSON properties and Transaction Logs for EntityFramework and EFCore
Stars: ✭ 82 (-21.9%)
Mutual labels:  entity-framework, entity-framework-core
EntityFrameworkCore.Triggered
Triggers for EFCore. Respond to changes in your DbContext before and after they are committed to the database.
Stars: ✭ 361 (+243.81%)
Mutual labels:  entity-framework, entity-framework-core
reconciler
Update an entity graph in store to a given one by inserting, updating and removing the respective entities.
Stars: ✭ 24 (-77.14%)
Mutual labels:  entity-framework, entity-framework-core
Uno.SQLitePCLRaw.Wasm
An SQLiteRaw WebAssembly provider for SQLitePCLRaw.core
Stars: ✭ 25 (-76.19%)
Mutual labels:  entity-framework, entity-framework-core
CodexMicroORM
An alternative to ORM's such as Entity Framework, offers light-weight database mapping to your existing CLR objects. Visit "Design Goals" on GitHub to see more rationale and guidance.
Stars: ✭ 32 (-69.52%)
Mutual labels:  entity-framework, entity-framework-core
EntityFrameworkCore.AutoFixture
A library aimed to minimize the boilerplate required to unit-test Entity Framework Core code using AutoFixture and in-memory providers.
Stars: ✭ 31 (-70.48%)
Mutual labels:  entity-framework, entity-framework-core
LinqBuilder
LinqBuilder is an advanced implementation of the specification pattern specifically targeting LINQ query generation.
Stars: ✭ 34 (-67.62%)
Mutual labels:  entity-framework, entity-framework-core
Efsecondlevelcache.core
Entity Framework Core Second Level Caching Library
Stars: ✭ 300 (+185.71%)
Mutual labels:  entity-framework, entity-framework-core
Entityframework.docs
Documentation for Entity Framework Core and Entity Framework 6
Stars: ✭ 888 (+745.71%)
Mutual labels:  entity-framework, entity-framework-core

BlazorWasmEFCoreExample

Image of data grid

Example of a Blazor WebAssembly project that uses Entity Framework Core on the server for data access.

Do you prefer Blazor Server instead? No problem! The same project is implemented for server here.

I created this series of blog posts to explain the project in detail (note: series is valid up to commit e6ac27b):

For the latest version, read about the latest round of refactoring here:

Thank you

🙏 Thanks to John Barrett for helping identify initial issues.

Features

  • Application hosted authentication and registration
  • Extended identity features to audit user creation, modification, email confirmation, and deletion
  • Entity Framework Core
  • Multiple data contexts
  • Entity Framework Core logging
  • Shadow properties: the database tracks row version, the user who created the entity and timestamp, and the user who last modified the entity and timestamp, without having to define these properties on the C# domain class
  • Automatic audit that tracks changes with a before/after snapshot and is generated at the data context level
  • Optimistic concurrency with delta resolution (when the database changes, the UI shows the changes so the user can overwrite or abort)
  • Entity validation on the client and server using data annotations
  • A grid that features paging, sorting, and filtering with debounce (i.e. typing three characters will result in just one database round trip)
  • Dynamic filtering and sorting with serverside evaluation
  • 99% of the UI is contained in a Razor class library that is usable from both Blazor WebAssembly and Blazor Server applications
  • Example of the repository pattern: the client and server use the same interface with a different implementation
  • Use of IHttpClientFactory to create a custom client with an authorization message handler

Quick start

Prerequisites

  • .NET Core SDK (3.1.300 or later)
  • Visual Studio Code, OR
  • Visual Studio 2019 16.6 or later

Code and Connection Strings

  1. Optionally fork the repository.

  2. Clone the repository (or your fork):

    git clone https://github.com/jeremylikness/BlazorWasmEFCoreExample.git

  3. If you don't have localdb installed, update appsettings.json and appsettings.Development.json in the ContactsApp.Server project to point to a valid database instance.

  4. The DefaultConnection is used for identity and can have any database name.

  5. The blazorcontactsdb is used for the application database and must match ContactContext.BlazorContactsDb in the ContactsApp.DataAccess project (the default value is blazorcontactsdb).

Visual Studio

  1. Open the solution file.

  2. Ensure the ContactsApp.Server project is set as the start up project.

  3. Open the NuGet Package Manager -> Package Manager Console.

  4. In the console, with the server project selected, create the identity migration by typing:

    Add-Migration -Context ApplicationAuditDbContext Initial

  5. After it is complete, apply the migration:

    Update-Database -Context ApplicationAuditDbContext

  6. You are ready to launch the application.

See note at the end of the next section.

Visual Studio Code

  1. Navigate to the ContactsApp/Server folder.

  2. If you haven't installed the EF Core Command Line Interface (CLI), install it by following these instructions. Choose the latest stable version (the project file currently ships with version 3.1.4).

  3. Run

    dotnet ef migrations add --context ApplicationAuditDbContext Initial

    to set up the identity database migrations.

  4. Run

    dotnet ef database update --context ApplicationAuditDbContext

    to create the identity database.

  5. Type

    dotnet run

    to start the server. Navigate to the port specified.

Note: the demo app is designed to create and populate the contacts database the first time you open the web page. This may result in a delay of up to several minutes on first load. This is normal and is just used to make setup easier. Subsequent runs should load faster.

Migrations for Contacts Database

The context for contacts (ContactContext) resides in the ContactsApp.DataAccess assembly. It is a .NET Standard class library and cannot be executed directly. I created a ContactContextFactory in the ContactsApp.Server project to enable migrations by using the SQL Server provider and loading the connection string. To create a migration, you must specify the executable startup project and the context name. This command will create a migration in the Migrations folder named InitialContact (assuming this is run from the root of the solution directory):

dotnet ef migrations add --startup-project ContactsApp/Server --context ContactContext InitialContact

Use the --namespace parameter to specify a different namespace to help avoid conflicts with the identity context.


Submit any feedback, questions, suggestions, or issues here.

Regards,

Jeremy Likness

@JeremyLikness

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].