{"id":20625105,"url":"https://github.com/jasonsturges/sqlite-dotnet-core","last_synced_at":"2026-03-07T04:01:48.758Z","repository":{"id":142401698,"uuid":"134502332","full_name":"jasonsturges/sqlite-dotnet-core","owner":"jasonsturges","description":".NET 8.0 Console Application using SQLite with Entity Framework and Dependency Injection","archived":false,"fork":false,"pushed_at":"2023-11-18T21:22:46.000Z","size":45,"stargazers_count":26,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T15:07:06.194Z","etag":null,"topics":["console-application","database","dependency-injection","dotnet","dotnet-core","entity-framework","sqlite"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jasonsturges.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-05-23T02:34:32.000Z","updated_at":"2025-03-05T08:47:29.000Z","dependencies_parsed_at":"2023-11-18T22:43:05.373Z","dependency_job_id":null,"html_url":"https://github.com/jasonsturges/sqlite-dotnet-core","commit_stats":null,"previous_names":[],"tags_count":2,"template":true,"template_full_name":null,"purl":"pkg:github/jasonsturges/sqlite-dotnet-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonsturges%2Fsqlite-dotnet-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonsturges%2Fsqlite-dotnet-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonsturges%2Fsqlite-dotnet-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonsturges%2Fsqlite-dotnet-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jasonsturges","download_url":"https://codeload.github.com/jasonsturges/sqlite-dotnet-core/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonsturges%2Fsqlite-dotnet-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30207392,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T03:24:23.086Z","status":"ssl_error","status_checked_at":"2026-03-07T03:23:11.444Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["console-application","database","dependency-injection","dotnet","dotnet-core","entity-framework","sqlite"],"created_at":"2024-11-16T13:08:09.943Z","updated_at":"2026-03-07T04:01:48.737Z","avatar_url":"https://github.com/jasonsturges.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQLite .NET 8 Console App\n.NET 8.0 Console Application using SQLite with Entity Framework and Dependency Injection\n\nThis example shows how to incorporate ASP.NET concepts such as dependency injection within a console application using [VS Code](https://code.visualstudio.com/) on macOS or linux targets.\n\n![vscode](https://user-images.githubusercontent.com/1213591/106406012-9d305c00-63fd-11eb-98e0-c2a0fca08afe.png)\n\n## Project Structure\n\nThis solution is divided into three projects:\n\n- **SqliteConsole**: The main console application\n- **SqliteConsole.Core**: Entity models\n- **SqliteConsole.Infrasture**: Entity framework database context and service classes\n\n## Concepts\n\nThe following concepts are demonstrated within this example console application project:\n- SQLite Entity Framework\n- Dependency Injection\n\n### SQLite Entity Framework\n\nUsing dependency injection, the database context can be passed to a constructor of a class:\n\n```cs\npublic class ExampleService : IExampleService\n{\n    private readonly SqliteConsoleContext context;\n\n    public ExampleService(SqliteConsoleContext sqliteConsoleContext)\n    {\n        context = sqliteConsoleContext;\n    }\n```\n\nThis way, the context may be used as follows:\n\n```cs\n    public void GetExamples()\n    {\n        var examples = context.Examples\n            .OrderBy(e =\u003e e.Name)\n            .ToList();\n```\n\nOtherwise, there's a factory method to instantiate new contexts:\n\n```cs\n    using (var context = SqliteConsoleContextFactory.Create(config.GetConnectionString(\"DefaultConnection\")))\n    {\n        var examples = context.Examples\n            .OrderBy(e =\u003e e.Name)\n            .ToList();\n    }\n```\n        \n### Dependency Injection\n\nService classes are added to the main console application's Program.cs:\n\n```cs\n// Services\nvar services = new ServiceCollection()\n    .AddSingleton\u003cIExampleService, ExampleService\u003e()\n    .BuildServiceProvider();\n```\n\nThen, obtain the instance of the service as:\n\n```cs\nvar service = services.GetService\u003cIExampleService\u003e();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonsturges%2Fsqlite-dotnet-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasonsturges%2Fsqlite-dotnet-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonsturges%2Fsqlite-dotnet-core/lists"}