{"id":20904788,"url":"https://github.com/angelodotnet/efcoregeneric","last_synced_at":"2026-01-05T05:41:31.604Z","repository":{"id":112275002,"uuid":"605697928","full_name":"AngeloDotNet/EFCoreGeneric","owner":"AngeloDotNet","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-21T14:02:05.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T08:55:47.776Z","etag":null,"topics":["hacktoberfest","hacktoberfest-accepted"],"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/AngeloDotNet.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}},"created_at":"2023-02-23T17:57:12.000Z","updated_at":"2024-03-27T18:54:27.000Z","dependencies_parsed_at":"2023-05-12T10:30:12.856Z","dependency_job_id":null,"html_url":"https://github.com/AngeloDotNet/EFCoreGeneric","commit_stats":null,"previous_names":["angelodotnet/efcoregeneric"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngeloDotNet%2FEFCoreGeneric","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngeloDotNet%2FEFCoreGeneric/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngeloDotNet%2FEFCoreGeneric/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngeloDotNet%2FEFCoreGeneric/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AngeloDotNet","download_url":"https://codeload.github.com/AngeloDotNet/EFCoreGeneric/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245195455,"owners_count":20575888,"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":["hacktoberfest","hacktoberfest-accepted"],"created_at":"2024-11-18T13:18:58.482Z","updated_at":"2026-01-05T05:41:31.575Z","avatar_url":"https://github.com/AngeloDotNet.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Entity Framework Core Generic\n\nIf you like this repository, please drop a :star: on Github!\n\n\n## Installation\n\nThe library is available on [NuGet](https://www.nuget.org/packages/EFCoreGeneric) or run the following command in the .NET CLI:\n\n```bash\ndotnet add package EFCoreGeneric\n```\n\n\n## Example entity\n\nIn this example, the entity is a data model that implements the *IEntity* interface and has a primary key of type *int*.\n\n```csharp\nnamespace MyNet6Project;\n\npublic class MyEntity : IEntity\u003cint\u003e\n{\n    public int Id { get; set; }\n    public string Name { get; set; }\n    public string Description { get; set; }\n}\n```\n\n\n## Example interface\n\nIn this example, the interface is a service that implements the *IMyService* interface.\n\n```csharp\nnamespace MyNet6Project;\n\npublic interface IMyService\n{\n    Task\u003cList\u003cMyEntity\u003e\u003e GetListItemAsync();\n    Task\u003cMyEntity\u003e GetItemAsync(int id);\n    Task CreateItemAsync(MyEntity item);\n    Task UpdateItemAsync(MyEntity item);\n    Task DeleteItemAsync(MyEntity item);\n}\n```\n\n\n## Example class\n\nIn this example, the class is a service that implements the *IMyService* interface.\n\n```csharp\nnamespace MyNet6Project;\n\npublic class MyService : IMyService\n{\n    private readonly IUnitOfWork\u003cMyEntity, int\u003e unitOfWork;\n\n    public MyService(IUnitOfWork\u003cMyEntity, int\u003e unitOfWork)\n    {\n        this.unitOfWork = unitOfWork;\n    }\n\n    public async Task\u003cList\u003cMyEntity\u003e\u003e GetListItemAsync()\n    {\n        var listItem = await unitOfWork.ReadOnly.GetAllAsync();\n        return listItem;\n    }\n\n    public async Task\u003cMyEntity\u003e GetItemAsync(int id)\n    {\n        var item = await unitOfWork.ReadOnly.GetByIdAsync(id);\n        return item;\n    }\n\n    public async Task CreateItemAsync(MyEntity item)\n    {\n        await unitOfWork.Command.CreateAsync(item);\n    }\n\n    public async Task UpdateItemAsync(MyEntity item)\n    {\n        await unitOfWork.Command.UpdateAsync(item);\n    }\n\n    public async Task DeleteItemAsync(MyEntity item)\n    {\n        await unitOfWork.Command.DeleteAsync(item);\n    }\n}\n```\n\n\n## Registering services at Startup\n\n```csharp\npublic void ConfigureServices(IServiceCollection services)\n{\n    services.AddScoped\u003cDbContext, DataDbContext\u003e();\n    services.AddScoped(typeof(IUnitOfWork\u003c,\u003e), typeof(UnitOfWork\u003c,\u003e));\n    services.AddScoped(typeof(IDatabaseRepository\u003c,\u003e), typeof(DatabaseRepository\u003c,\u003e));\n    services.AddScoped(typeof(ICommandRepository\u003c,\u003e), typeof(CommandRepository\u003c,\u003e));\n}\n```\n\n\n## Contributing\n\nContributions and/or suggestions are always welcome.\n\n\n## Badges\n\n[![Publish](https://github.com/AngeloDotNet/EFCoreGenericLibraryV3/actions/workflows/publish.yml/badge.svg?branch=main)](https://github.com/AngeloDotNet/EFCoreGenericLibraryV3/actions/workflows/publish.yml)\n\n[![Lint Code Base](https://github.com/AngeloDotNet/EFCoreGenericLibraryV3/actions/workflows/linter.yml/badge.svg?branch=main)](https://github.com/AngeloDotNet/EFCoreGenericLibraryV3/actions/workflows/linter.yml)\n\n[![CodeQL](https://github.com/AngeloDotNet/EFCoreGenericLibraryV3/actions/workflows/codeql.yml/badge.svg?branch=main)](https://github.com/AngeloDotNet/EFCoreGenericLibraryV3/actions/workflows/codeql.yml)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangelodotnet%2Fefcoregeneric","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangelodotnet%2Fefcoregeneric","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangelodotnet%2Fefcoregeneric/lists"}