{"id":30237890,"url":"https://github.com/egorikas/dot-net-core-shared-configuration","last_synced_at":"2026-04-16T00:32:57.491Z","repository":{"id":143651086,"uuid":"97954047","full_name":"egorikas/dot-net-core-shared-configuration","owner":"egorikas","description":"Example of the shared .net configuration project.","archived":false,"fork":false,"pushed_at":"2017-07-23T18:07:21.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-15T03:03:23.959Z","etag":null,"topics":["asp-net-core","asp-net-mvc","configuration","dot-net","shared","shared-configuration"],"latest_commit_sha":null,"homepage":"","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/egorikas.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-07-21T14:05:12.000Z","updated_at":"2018-01-15T13:17:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"d5066290-d04a-4870-ad57-77f350b9133c","html_url":"https://github.com/egorikas/dot-net-core-shared-configuration","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/egorikas/dot-net-core-shared-configuration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egorikas%2Fdot-net-core-shared-configuration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egorikas%2Fdot-net-core-shared-configuration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egorikas%2Fdot-net-core-shared-configuration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egorikas%2Fdot-net-core-shared-configuration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egorikas","download_url":"https://codeload.github.com/egorikas/dot-net-core-shared-configuration/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egorikas%2Fdot-net-core-shared-configuration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31866347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["asp-net-core","asp-net-mvc","configuration","dot-net","shared","shared-configuration"],"created_at":"2025-08-15T02:57:45.685Z","updated_at":"2026-04-16T00:32:57.479Z","avatar_url":"https://github.com/egorikas.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# .NET Core shared configuration example\n[![Build status](https://ci.appveyor.com/api/projects/status/0m9y8kj9mjujqi14?svg=true)](https://ci.appveyor.com/project/EgorGrishechko/dot-net-core-shared-configuration)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)\n\n## What is the reason?\n\nNew configuration system for .NET Core is really awesome.\nBut in official stylyguides it always uses in the main ASP.NET Core app.\nBut what if we have other apps in the solution? Or we need to share configuration settings between projects?\nAdditional info in my [blog-post](http://egorikas.com/asp.net-core-shared-configuration/).\n\n### Entity Framework Core\n\nIt's even getting worse, when we want to use `Migrations` from [EF Core](https://docs.microsoft.com/en-us/ef/).\nIf we don't have parameter less constructor in our `DbContext`, there is a need for implementing `IDbContextFactory`.\nAnd in this case we star to face off a problem with passing `connection string` to our context. \n\n[Official documentation](https://docs.microsoft.com/en-us/ef/core/miscellaneous/configuring-dbcontext) contains an example with hard-coded connection string\n```csharp\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\n\nnamespace MyProject\n{\n    public class BloggingContextFactory : IDbContextFactory\u003cBloggingContext\u003e\n    {\n        public BloggingContext Create()\n        {\n            var optionsBuilder = new DbContextOptionsBuilder\u003cBloggingContext\u003e();\n            optionsBuilder.UseSqlite(\"Data Source=blog.db\");\n\n            return new BloggingContext(optionsBuilder.Options);\n        }\n    }\n}\n```\nI don't think, that this is a flexible and right way to do this kind of fabric.\n\nSo, with the solution has been written by me, it looks in the next way\n```csharp\nusing Microsoft.EntityFrameworkCore;\nusing Microsoft.EntityFrameworkCore.Infrastructure;\n\nnamespace MyProject\n{\n    public class BloggingContextFactory : IDbContextFactory\u003cBloggingContext\u003e\n    {\n        public BloggingContext Create()\n        {\n            var configurationRoot = SettingsProvider.GetConfigurationRoot(new EnvironmentProvider());\n            \n            var optionsBuilder = new DbContextOptionsBuilder\u003cBloggingContext\u003e();\n            //In my project I put \"mainDb\" to ConfigurationConstants class\n            optionsBuilder.UseSqlite(configurationRoot.GetConnectionString(\"mainDb\"));\n\n            return new BloggingContext(optionsBuilder.Options);\n        }\n    }\n}\n```\nThere is the [article](https://www.benday.com/2017/02/17/ef-core-migrations-without-hard-coding-a-connection-string-using-idbcontextfactory/) with the alternative way for solving this problem. But I don't like it due to low flexibility of configuration settings.\n\n## Build\n\nInstall [.NET Core SDK](https://www.microsoft.com/net/download/core \"official site\")\n\nOpen folder with `Configuration.sln` in the shell.\nThen \n```\n    dotnet restore\n    dotnet build\n```\n## Tests\nOpen folder with `Configuraion.Test.csproj` in the shell.\nThen\n```\n    dotnet test\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegorikas%2Fdot-net-core-shared-configuration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegorikas%2Fdot-net-core-shared-configuration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegorikas%2Fdot-net-core-shared-configuration/lists"}