{"id":25807046,"url":"https://github.com/fdonnet/dapper-layers-generator","last_synced_at":"2025-06-23T17:35:17.808Z","repository":{"id":62908010,"uuid":"559311550","full_name":"fdonnet/Dapper-Layers-Generator","owner":"fdonnet","description":"Automate layers generation for dapper (DAL/ POCO/ maybe API), based on database definitions. Read your DB and generate a lot of stuff to access your data.","archived":false,"fork":false,"pushed_at":"2023-09-12T07:10:13.000Z","size":452,"stargazers_count":3,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T04:13:39.469Z","etag":null,"topics":["asp-net","async","console-application","csharp","dal","dapper","dbcontext","generators","linux-x64","mysql","net7","poco","spectre-console","win-x64"],"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/fdonnet.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":"2022-10-29T18:07:59.000Z","updated_at":"2024-12-06T07:17:03.000Z","dependencies_parsed_at":"2025-02-27T21:21:10.938Z","dependency_job_id":"153e3385-6587-49bc-9449-0a16fa5e2dd6","html_url":"https://github.com/fdonnet/Dapper-Layers-Generator","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/fdonnet/Dapper-Layers-Generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdonnet%2FDapper-Layers-Generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdonnet%2FDapper-Layers-Generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdonnet%2FDapper-Layers-Generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdonnet%2FDapper-Layers-Generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fdonnet","download_url":"https://codeload.github.com/fdonnet/Dapper-Layers-Generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdonnet%2FDapper-Layers-Generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261523097,"owners_count":23171957,"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":["asp-net","async","console-application","csharp","dal","dapper","dbcontext","generators","linux-x64","mysql","net7","poco","spectre-console","win-x64"],"created_at":"2025-02-27T20:56:45.936Z","updated_at":"2025-06-23T17:35:17.769Z","avatar_url":"https://github.com/fdonnet.png","language":"C#","readme":"# Dapper-Layers-Generator\n\n**For the \"always DB first\" lovers**:heart:\n\nGenerate all the ez and boring DAL accesses you need at the begining with dapper and you will be able to focus on the complex parts of your app!\nAt the end, you will keep the control and can extend the code.\n\n---\n\nRead DB definitions from:\n\n- [x] MySql / MariaDB\n- [ ] MsSql (will be next)\n- [ ] PostGreSQL\n- [ ] Oracle\n\nGenerated C# code based on your db definitions:\n\n- [x] Poco / Entities for all tables\n- [x] DbContext / DbContext factory (simple)\n- [x] DAL base implementation (multi-dbs)\n- [x] DAL MySql / Maria DB specifics\n- [ ] DAL MsSql DB specifics (will be next)\n- [ ] DAL PostGreSQL specifics\n- [ ] DAL Oracle specifics\n\nAlready implemented DAL methods in the generated code:\n\n` all the generated methods will have custom names based on your columns def, if your pk is \"id\" the generated method becomes GetByIdAsync(), if your unique index is on columns \"firstname\" and \"lastname\" the generated method name becomes GetByFirstnameAndLastNameAsync() etc) `\n\n- [x] GetAllAsync()\n- [x] GetByPkAsync()\n- [x] GetByListOfPKAsync()\n- [x] GetByListOfPKBulkAsync() with MySqlBulkCopy and temp table\n- [x] GetByUniqueIndexAsync()\n- [x] AddAsync()\n- [x] AddMultiAsync()\n- [x] AddBulkAsync(), with MySqlBulkCopy\n- [x] UpdateAsync()\n- [x] UpdateMultiAsync()\n- [x] UpdateBulkAsync(), with MySqlBulkCopy and temp table\n- [x] DeleteAsync()\n- [x] DeletebyPkListAsync()\n- [x] DeleteBulkAsync(), with MySqlBulkCopy and temp table\n\n---\n\n## Config and first simple start\n\nSet the mandatory configs in appsettings or environnement or usersecrets\n\n```json\n{\n  \"ConnectionStrings\": {\n    \"Default\": \"Server=localhost;Database=information_schema;Uid=root;Pwd=root;\"\n  },\n\n  \"DB\": {\n    \"Schemas\": \"testschema\",\n    \"Provider\": \"MySql\"\n  }\n}\n```\n\n- ConnectionStrings:Default =\u003e a MySql/Mariadb connection string with read right on information_schema\n- DB:Schemas =\u003e the schemas/db name you want to read the definitions from to be able to generate your layers code\n- DB:Provider =\u003e only MySql supported now.\n\n## Run the app\n\n![MainMenu](doc/img/main.jpg)\n\n===\u003e Go on \"Main settings\"\n\n![MainSettings](doc/img/main-settings.JPG)\n\nSet at least the following configs\n\n- (3) Author name: your name\n- (4) Target project namespace: the main namespace for your generated code\n- (8) Target project path: physical path (where you want to generate) =\u003e don't forget the last backslash \"\\\\\"\n\nCheck all the path specified exist on your file system. The generator will not create the folder structure.\n\nPress (q) to go back to the main menu.\n\n## On the main menu, choose \"Save\"\n\n![Save](doc/img/save.jpg)\n\nComplete path/filename.json where you want to save your config.\n\n## Generate\n\n![Generate](doc/img/generate.jpg)\n\nAfter your first code generation, return, load your config file and test all the available settings in (General settings / adavanced settings). You can go deeper as column config. I let you discover.\n\n---\n\n## Generated code usage\n\nIn your net6 app/asp.net, register the dbcontext :\n\n```cs\nIServiceCollection _services = new ServiceCollection()\n    .AddSingleton(_config)\n    .AddTransient\u003cIDbContext, DbContextMySql\u003e();\n```\n\nand call your new generated dal in your controller/service or app :\n\n```cs\nvar clients = await dal.ClientRepo.GetAllAsync();\n```\n\nwith transaction :\n\n```cs\nusing var trans = await dal.OpenTransactionAsync();\nint newClientId = await dal.ClientRepo.AddAsync(new Client() { Firstname = \"John\", Lastname = \"Smith\", City = \"Paris\" });\nint newFailureId = await dal.FailureRepo.AddAsync(new Failure() { Description=\"Fail to pass the door\", ClientId = newClientId });\ndal.CommitTransaction();\n```\n\n### If you want to extent the generated code, create a new file and declare a partial class with the same name as the class you want to extent !\n\nOpen an issue if you have specific questions or if you detect an issue !\n\nAnd love for\n\n\u003chttps://github.com/DapperLib/Dapper\u003e\n\n\u003chttps://github.com/spectreconsole/spectre.console\u003e\n\n\u003chttps://github.com/Humanizr/Humanizer\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdonnet%2Fdapper-layers-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffdonnet%2Fdapper-layers-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdonnet%2Fdapper-layers-generator/lists"}