{"id":13429656,"url":"https://github.com/Finbuckle/Finbuckle.MultiTenant","last_synced_at":"2025-03-16T03:32:03.235Z","repository":{"id":24641261,"uuid":"102116094","full_name":"Finbuckle/Finbuckle.MultiTenant","owner":"Finbuckle","description":"Finbuckle.MultiTenant is an open-source multitenancy middleware library for .NET. It enables tenant resolution, per-tenant app behavior, and per-tenant data isolation.","archived":false,"fork":false,"pushed_at":"2025-03-14T04:07:53.000Z","size":2889,"stargazers_count":1387,"open_issues_count":118,"forks_count":272,"subscribers_count":41,"default_branch":"main","last_synced_at":"2025-03-15T07:04:40.722Z","etag":null,"topics":["aspnetcore","aspnetcore-identity","dotnet","dotnetcore","efcore","entity-framework-core","finbuckle","middleware","multitenant"],"latest_commit_sha":null,"homepage":"https://www.finbuckle.com/multitenant","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Finbuckle.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":"FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["finbuckle"]}},"created_at":"2017-09-01T13:33:35.000Z","updated_at":"2025-03-14T22:43:21.000Z","dependencies_parsed_at":"2023-02-16T05:01:31.549Z","dependency_job_id":"bb394428-c3af-4bdd-a025-12fe57916f39","html_url":"https://github.com/Finbuckle/Finbuckle.MultiTenant","commit_stats":{"total_commits":328,"total_committers":38,"mean_commits":8.631578947368421,"dds":"0.22560975609756095","last_synced_commit":"9e84fa62a5056eae24012194bfc5ba3956ac4a07"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Finbuckle%2FFinbuckle.MultiTenant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Finbuckle%2FFinbuckle.MultiTenant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Finbuckle%2FFinbuckle.MultiTenant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Finbuckle%2FFinbuckle.MultiTenant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Finbuckle","download_url":"https://codeload.github.com/Finbuckle/Finbuckle.MultiTenant/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243822310,"owners_count":20353496,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnetcore","aspnetcore-identity","dotnet","dotnetcore","efcore","entity-framework-core","finbuckle","middleware","multitenant"],"created_at":"2024-07-31T02:00:43.297Z","updated_at":"2025-03-16T03:32:03.229Z","avatar_url":"https://github.com/Finbuckle.png","language":"C#","funding_links":["https://github.com/sponsors/finbuckle","https://github.com/sponsors/Finbuckle"],"categories":["Frameworks, Libraries and Tools","框架, 库和工具","C# #"],"sub_categories":["Application Frameworks","应用程序框架"],"readme":"# ![Finbuckle Logo](https://www.finbuckle.com/images/finbuckle-32x32-gh.png) Finbuckle.MultiTenant \u003cspan class=\"_version\"\u003e9.1.0\u003c/span\u003e\n\n## About Finbuckle.MultiTenant\n\nFinbuckle.MultiTenant is an open-source multitenancy middleware library for .NET. It enables tenant resolution,\nper-tenant app behavior, and per-tenant data isolation.\nSee [https://www.finbuckle.com/multitenant](https://www.finbuckle.com/multitenant) for more details and documentation.\n\n**This release supports .NET 9 and .NET 8.**\n\n## Open Source Support\n\nTable of Contents\n\n1. [What's New in v\u003cspan class=\"_version\"\u003e9.1.0\u003c/span\u003e](#whats-new)\n2. [Open Source Support](#open-source-support)\n3. [Quick Start](#quick-start)\n4. [Documentation](#documentation)\n5. [Sample Projects](#sample-projects)\n6. [Build and Test Status](#build-and-test-status)\n7. [License](#license)\n8. [.NET Foundation](#net-foundation)\n9. [Code of Conduct](#code-of-conduct)\n10. [Community](#community)\n11. [Building from Source](#building-from-source)\n12. [Running Unit Tests](#running-unit-tests)\n\n## \u003ca name=\"whats-new\"\u003e\u003c/a\u003e What's New in v\u003cspan class=\"_version\"\u003e9.1.0\u003c/span\u003e\n\n\u003e This section only lists release update details specific to v\u003cspan class=\"_version\"\u003e9.1.0\u003c/span\u003e. See\n\u003e the [changelog file](CHANGELOG.md) for all release update details.\n\u003c!--_release-notes--\u003e\n\n### Features\n\n* add WithDelegateStrategy\u003cTContext, TTenantInfo\u003e ([#932](https://github.com/Finbuckle/Finbuckle.MultiTenant/issues/932)) ([a18a935](https://github.com/Finbuckle/Finbuckle.MultiTenant/commit/a18a935ea397b4cbd9e52fdcee589212db9d0999))\n* add WithHttpContextStrategy ([#934](https://github.com/Finbuckle/Finbuckle.MultiTenant/issues/934)) ([e6aeb7c](https://github.com/Finbuckle/Finbuckle.MultiTenant/commit/e6aeb7c9c265d39eb4bec0d2be526f582f41f886))\n* better async pattern for class libraries ([#942](https://github.com/Finbuckle/Finbuckle.MultiTenant/issues/942)) ([8235462](https://github.com/Finbuckle/Finbuckle.MultiTenant/commit/82354625d24ced67228246885f9f326389209e9c))\n* improved perf for HostStrategy ([#936](https://github.com/Finbuckle/Finbuckle.MultiTenant/issues/936)) ([a70f7e0](https://github.com/Finbuckle/Finbuckle.MultiTenant/commit/a70f7e0f47eaf180e5f64f1bba61cae59086251a))\n\n### Bug Fixes\n\n* added new analyzers and multiple fixes  ([#937](https://github.com/Finbuckle/Finbuckle.MultiTenant/issues/937)) ([9d9b1e4](https://github.com/Finbuckle/Finbuckle.MultiTenant/commit/9d9b1e416929ebbd795c0eef3361cca7d6d238ce))\n* MultiTenantDbContext.Create should have non nullable TenantInfo ([#916](https://github.com/Finbuckle/Finbuckle.MultiTenant/issues/916)) ([9df0527](https://github.com/Finbuckle/Finbuckle.MultiTenant/commit/9df0527841549e0dd6e2017cfff3ebc6f03b7e16))\n\u003c!--_release-notes--\u003e\n\n## Open Source Support\n\nYour support helps keep the project going and is greatly appreciated!\n\nFinbuckle.MultiTenant is primarily supported by its [GitHub sponsors](https://github.com/sponsors/Finbuckle) and [contributors](https://github.com/Finbuckle/Finbuckle.MultiTenant/graphs/contributors).  \n\nAdditional support is provided by the following organizations:\n\n\u003cp\u003e\u003ca href=\"https://www.digitalocean.com/\"\u003e\n  \u003cimg src=\"https://opensource.nyc3.cdn.digitaloceanspaces.com/attribution/assets/SVG/DO_Logo_horizontal_blue.svg\" alt=\"Digital Ocean logo\" height=\"40\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n\u003cp\u003e\u003ca href=\"https://www.github.com/\"\u003e\n  \u003cimg src=\"https://github.githubassets.com/assets/GitHub-Logo-ee398b662d42.png\" alt=\"GitHub logo\" height=\"40\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n\u003cp\u003e\u003ca href=\"https://www.jetbrains.com/\"\u003e\n  \u003cimg src=\"https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg\" alt=\"Jetbrains logo\" height=\"40\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n## Quick Start\n\nFinbuckle.MultiTenant is designed to be easy to use and follows standard .NET conventions as much as possible. This\nintroduction assumes a standard ASP.NET Core use case, but any application using .NET dependency injection can work with\nthe library.\n\n### Installation\n\nFirst, install the Finbuckle.MultiTenant.AspNetCore NuGet package:\n\n.NET Core CLI\n\n```bash\n$ dotnet add package Finbuckle.MultiTenant.AspNetCore\n```\n\n### Basic Configuration\n\nNext, in the app's service configuration call `AddMultiTenant\u003cTTenantInfo\u003e` and its various builder methods and in the\nmiddleware configuration call `UseMultiTenant()`:\n\n```cs\nbuilder.Services.AddMultiTenant\u003cTenantInfo\u003e()\n    .WithHostStrategy()\n    .WithConfigurationStore();\n\n// other app code...\n\napp.UseMultiTenant();\n\n// other app code...\n\napp.Run();\n```\n\nThat's all that is needed to get going. Let's breakdown each line:\n\n`builder.Services.AddMultiTenant\u003cTenantInfo\u003e()`\n\nThis line registers the base services and designates `TenantInfo` as the class that will hold tenant information at\nruntime.\n\nThe type parameter for `AddMultiTenant\u003cTTenantInfo\u003e` must be an implementation of `ITenantInfo` which holds basic\ninformation about the tenant such as its name and an identifier. `TenantInfo` is provided as a basic implementation, but\na custom implementation can be used if more properties are needed.\n\nSee [Core Concepts](https://www.finbuckle.com/MultiTenant/Docs/CoreConcepts) for more information on `ITenantInfo`.\n\n`.WithHostStrategy()`\n\nThe line tells the app that our \"strategy\" to determine the request tenant will be to look at the request host, which\ndefaults to the extracting the subdomain as a tenant identifier.\n\nSee [MultiTenant Strategies](https://www.finbuckle.com/MultiTenant/Docs/Strategies) for more information.\n\n`.WithConfigurationStore()`\n\nThis line tells the app that information for all tenants are in the `appsettings.json` file used for app configuration.\nIf a tenant in the store has the identifier found by the strategy, the tenant will be successfully resolved for the\ncurrent request.\n\nSee [MultiTenant Stores](https://www.finbuckle.com/MultiTenant/Docs/Stores) for more information.\n\nFinbuckle.MultiTenant comes with a collection of strategies and store types that can be mixed and matched in various\nways.\n\n`app.UseMultiTenant()`\n\nThis line configures the middleware which resolves the tenant using the registered strategies, stores, and other\nsettings. Be sure to call it before other middleware which will use per-tenant functionality, e.g.\n`UseAuthentication()`.\n\n### Basic Usage\n\nWith the services and middleware configured, access information for the current tenant from the `TenantInfo` property on\nthe `MultiTenantContext\u003cT\u003e` object accessed from the `GetMultiTenantContext\u003cT\u003e` extension method:\n\n```cs\nvar tenantInfo = HttpContext.GetMultiTenantContext\u003cTenantInfo\u003e().TenantInfo;\n\nif(tenantInfo != null)\n{\n    var tenantId = tenantInfo.Id;\n    var identifier = tenantInfo.Identifier;\n    var name = tenantInfo.Name;\n}\n```\n\nThe type of the `TenantInfo` property depends on the type passed when calling `AddMultiTenant\u003cT\u003e` during configuration.\nIf the current tenant could not be determined then `TenantInfo` will be null.\n\nThe `ITenantInfo` instance and/or the typed instance are also available directly through dependency injection.\n\nSee [Configuration and Usage](https://www.finbuckle.com/MultiTenant/Docs/ConfigurationAndUsage) for more information.\n\n## Documentation\n\nThe library builds on this basic functionality to provide a variety of higher level features. See\nthe [documentation](https://www.finbuckle.com/multitenant/docs) for more details:\n\n* [Per-tenant Options](https://www.finbuckle.com/MultiTenant/Docs/Options)\n* [Per-tenant Authentication](https://www.finbuckle.com/MultiTenant/Docs/Authentication)\n* [Entity Framework Core Data Isolation](https://www.finbuckle.com/MultiTenant/Docs/EFCore)\n* [ASP.NET Core Identity Data Isolation](https://www.finbuckle.com/MultiTenant/Docs/Identity)\n\n## Sample Projects\n\nA variety of [sample projects](https://github.com/Finbuckle/Finbuckle.MultiTenant/tree/main/samples) are available in\nthe repository. Check older tagged release commits for samples from prior .NET versions.\n\n## Build and Test Status\n\n![Build and Test Status](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/ci.yml/badge.svg)\n\n## License\n\nThis project uses the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0). See [LICENSE](LICENSE) file for\nlicense information.\n\n## .NET Foundation\n\nThis project is supported by the [.NET Foundation](https://dotnetfoundation.org).\n\n## Code of Conduct\n\nThis project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our\ncommunity. For more information see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct)\nor the [CONTRIBUTING.md](CONTRIBUTING.md) file.\n\n## Community\n\nCheck out the [GitHub repository](https://github.com/Finbuckle/Finbuckle.MultiTenant) to ask a question, make a request,\nor peruse the code!\n\n## Building from Source\n\nFrom the command line clone the git repository, `cd` into the new directory, and compile with `dotnet build`.\n\n```bash\n$ git clone https://github.com/Finbuckle/Finbuckle.MultiTenant.git\n$ cd Finbuckle.MultiTenant\nCloning into 'Finbuckle.MultiTenant'...\n\u003coutput omitted\u003e\n$ cd Finbuckle.MultiTenant\n$ dotnet build\n```\n\n## Running Unit Tests\n\nRun the unit tests from the command line with `dotnet test` from the solution directory.\n\n```bash\n$ dotnet test\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFinbuckle%2FFinbuckle.MultiTenant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFinbuckle%2FFinbuckle.MultiTenant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFinbuckle%2FFinbuckle.MultiTenant/lists"}