dotnet / dotnet/EntityFramework.Docs

Documentation about using sharding with ASP.NET Core and EFCore

Open
#2,450 6 comments 1 reaction 0 assignees View on GitHub
area-global new-pm
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

For 5 years we have a .NET v4.6 application using EF6 and sharding. This is an internal application hosted by Azure used by a dozen users.
When a user creates a new client, the application saves the client details in the client table in the Master database, next it creates a new shard/tenant database. All other data of this client will be saved in this new database.
We use more or less this code example: https://docs.microsoft.com/en-us/azure/sql-database/sql-database-elastic-scale-use-entity-framework-applications-visual-studio

At this moment I'm rebuilding the application using .NET Core, Blazor, and EFCore. I managed to migrate most of the code pieces except for the sharding part.
My code is available at https://bitbucket.org/pmeems/matblazorgooglegsuite/src/develop/

As I see it, the difference between my .NET Core application and my .NET classic application is how the tenant context is created.
For .NET Core, I need to do something in startup.cs.
I also asked about this at StackOverflow: https://stackoverflow.com/questions/61632457/how-to-use-database-sharding-with-ef-core-and-c
David Browne (from Microsoft) is at least suggestion it should be possible but is only showing parts of what I should do.

We also use MultiShardConnection to search for employees in all client databases. It's not clear to me as well what the EFCore counterpart is.

What I'm looking for is a full example of how to implement sharding with .NET Core and EFCore.
I can't find any examples. I did find other people asking similar questions and not finding any answers either.

I'm stuck with this for weeks now. Any guidance will be much appreciated.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.