Skip to content

Commit

Permalink
chore: update links to samples in Stores.md (#793)
Browse files Browse the repository at this point in the history
Many samples are removed from v6.10 and up, so the links need to be referencing the latest tag that got those samples.
  • Loading branch information
eloekset authored Apr 23, 2024
1 parent 9042048 commit ef2c4c1
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions docs/Stores.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,26 @@ of `ITenantInfo` properties are mapped from the JSON automatically.

Uses an Entity Framework Core database context as the backing store.

Case sensitivity will vary by how the database context is configured and the underlying database provider. The database
context must derive from `EFCoreStoreDbContext` and additional entity types can be added.
This store is usually case-sensitive when retrieving tenant information by tenant identifier, depending on the underlying database.

The database context should derive from `EFCoreStoreDbContext`. The code examples below are taken from
the [EFCore Store Sample](https://github.com/Finbuckle/Finbuckle.MultiTenant/tree/v6.9.1/samples/ASP.NET%20Core%203/EFCoreStoreSample)
.

The database context used with the EFCore store must derive from `EFCoreStoreDbContext`, but other entities can be
added:

```csharp
public class MultiTenantStoreDbContext : EFCoreStoreDbContext<TenantInfo>
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// Use InMemory, but could be MsSql, Sqlite, MySql, etc...
optionsBuilder.UseInMemoryDatabase("EfCoreStoreSampleConnectionString");
base.OnConfiguring(optionsBuilder);
}
}
```

This database context is not itself multi-tenant, but rather it globally contains the details of each tenant.
It will often be a standalone database separate from any tenant database(s) and will have its own connection string.
Expand All @@ -171,15 +189,17 @@ Entity Framework Core works with any database context which can offer richer fun

> NuGet package: Finbuckle.MultiTenant

Sends the tenant identifier, provided by the [MultiTenant strategy](Strategies), to an http(s) endpoint to get
a `TenantInfo` object in return. This store is usually case insensitive when retrieving tenant information by tenant
identifier, but the remote server might be more restrictive.
Sends the tenant identifier, provided by the multitenant strategy, to an http(s) endpoint to get a `TenantInfo` object
in return.

The [Http Remote Store Sample](https://github.com/Finbuckle/Finbuckle.MultiTenant/tree/v6.9.1/samples/ASP.NET%20Core%203/HttpRemoteStoreSample)
projects demonstrate this store. This store is usually case insensitive when retrieving tenant information by tenant identifier, but the remote server might be more restrictive.

Make sure the tenant info type will support basic JSON serialization and deserialization via `System.Text.Json`.
This strategy will attempt to deserialize the tenant using the [System.Text.Json web defaults](https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-configure-options?pivots=dotnet-6-0#web-defaults-for-jsonserializeroptions).
For a successfully request, the store expects a 200 response code and a json body with properties `Id`, `Identifier`
, `Name`, and `ConnectionString` and other properties which will be mapped into a `TenantInfo` object with the type
, `Name`, and other properties which will be mapped into a `TenantInfo` object with the type
passed to `AddMultiTenant<TTenantInfo>`.

Any non-200 response code results in a null `TenantInfo`.
Expand Down Expand Up @@ -251,4 +271,4 @@ services.AddMultiTenant<TenantInfo>()
// or set a 5 minute sliding expiration.
services.AddMultiTenant<TenantInfo>()
.WithDistributedCacheStore(TimeSpan.FromMinutes(5));
```
```

0 comments on commit ef2c4c1

Please sign in to comment.