{"id":37039186,"url":"https://github.com/unosquare/tenantcore","last_synced_at":"2026-01-14T04:39:05.314Z","repository":{"id":34113120,"uuid":"37942808","full_name":"unosquare/tenantcore","owner":"unosquare","description":"TenantCore, OWIN multitenancy","archived":true,"fork":false,"pushed_at":"2019-07-26T15:45:42.000Z","size":551,"stargazers_count":10,"open_issues_count":0,"forks_count":5,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-10-06T00:09:28.096Z","etag":null,"topics":["dbcontext","tenant","tenant-resolver"],"latest_commit_sha":null,"homepage":"https://unosquare.github.io/tenantcore/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unosquare.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-23T20:21:30.000Z","updated_at":"2023-10-11T04:47:16.000Z","dependencies_parsed_at":"2022-07-31T11:17:57.392Z","dependency_job_id":null,"html_url":"https://github.com/unosquare/tenantcore","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/unosquare/tenantcore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unosquare%2Ftenantcore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unosquare%2Ftenantcore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unosquare%2Ftenantcore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unosquare%2Ftenantcore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unosquare","download_url":"https://codeload.github.com/unosquare/tenantcore/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unosquare%2Ftenantcore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28409684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dbcontext","tenant","tenant-resolver"],"created_at":"2026-01-14T04:39:04.558Z","updated_at":"2026-01-14T04:39:05.307Z","avatar_url":"https://github.com/unosquare.png","language":"C#","readme":"[![NuGet version](https://badge.fury.io/nu/tenantcore.svg)](http://badge.fury.io/nu/tenantcore)\n[![Build Status](https://travis-ci.org/unosquare/tenantcore.svg?branch=master)](https://travis-ci.org/unosquare/tenantcore)\n[![Analytics](https://ga-beacon.appspot.com/UA-8535255-2/unosquare/tenantcore/)](https://github.com/igrigorik/ga-beacon)\n# TenantCore\n\n**Important** - This repository has been archived. We are not longer maintaining  this project.\n\nTenantCore is an OWIN Middleware that it can help to resolve tenants, a multitenancy middleware, by request's hostname for example or by any resolver. You can create your own Tenant's resolver or use the default one. The tenant can have a database connection string or any property that you need.\n\nTo start you need to setup the Resolver and Tenants in your OWIN AppBuilder, for example:\n\n```csharp\npublic void ConfigureAuth(IAppBuilder app)\n{\n    // SetUp Multitenancy with TenantCore\n    var tenants = new List\u003cITenant\u003e\n    {\n        new Tenant(\"local\", \"localhost\", @\"Data Source=(LocalDb)\\v11.0;AttachDbFilename=|DataDirectory|\\local.mdf;Initial Catalog=local;Integrated Security=True\"),\n        new Tenant(\"sample\", \"sample.local\", @\"Data Source=(LocalDb)\\v11.0;AttachDbFilename=|DataDirectory|\\sample.mdf;Initial Catalog=sample;Integrated Security=True\"),\n        new Tenant(\"fake\", \"fake.local\", @\"Data Source=(LocalDb)\\v11.0;AttachDbFilename=|DataDirectory|\\fake.mdf;Initial Catalog=fake;Integrated Security=True\")\n    };\n            \n    app.UseTenantCore(new HostNameTenantResolver(tenants));\n\n    // Configure the db context and user manager to use a single instance per request\n    app.CreatePerOwinContext\u003cApplicationDbContext\u003e(ApplicationDbContext.Create);\n    app.CreatePerOwinContext\u003cApplicationUserManager\u003e(ApplicationUserManager.Create);\n\n    // And continue with your middleware and settings\n}\n```\n\nIf you want to have a database per tenant, you need to change your DbContext or IdentityDbContext to have a Create method\nwith parameters:\n\n```csharp\npublic static ApplicationDbContext Create(IdentityFactoryOptions\u003cApplicationDbContext\u003e options,\n    IOwinContext context)\n{\n    return context.GetDbContext\u003cApplicationDbContext\u003e();\n}\n```\n\nThe GetDbContext is an extension method in TenantCore, it will find the current Tenant and get the ConnectionString. The ConnectionString\nwill be used with your DbContext, so be sure to have a constructor with connectionstring param like this:\n\n```csharp\npublic ApplicationDbContext(string connectionString)\n            : base(connectionString, throwIfV1Schema: false) {}\n```\n\nNow in your ApiController you can use the Tenant or DbContext with some extension methods, for example:\n\n```csharp\n[HttpGet, Route(\"register/{id}\")]\npublic async Task\u003cIHttpActionResult\u003e Register(string id)\n{\n    // Gets the DbContext related to current Tenant\n    var database = HttpContext.Current.GetDbContext\u003cApplicationDbContext\u003e();\n    // Gets the current Tenant\n    var tenant = HttpContext.Current.GetCurrentTenant();\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funosquare%2Ftenantcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funosquare%2Ftenantcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funosquare%2Ftenantcore/lists"}