diff --git a/README.md b/README.md index 07d4297e0..c99573bef 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# RSCG - 277 Examples of Roslyn Source Code Generators / 16 created by Microsoft / +# RSCG - 278 Examples of Roslyn Source Code Generators / 16 created by Microsoft / -The RSCG_Examples repository is a comprehensive documentation system that automatically processes and showcases 277 Roslyn Source Code Generator (RSCG) examples. The system transforms individual RSCG projects into structured documentation with code examples and cross-referenced content with a searchable website and code example exports. +The RSCG_Examples repository is a comprehensive documentation system that automatically processes and showcases 278 Roslyn Source Code Generator (RSCG) examples. The system transforms individual RSCG projects into structured documentation with code examples and cross-referenced content with a searchable website and code example exports. This system serves as both a learning resource for .NET developers interested in source generators and an automated pipeline for maintaining up-to-date documentation about the RSCG ecosystem -## Latest Update : 2026-07-04 => 04 July 2026 +## Latest Update : 2026-08-18 => 18 August 2026 If you want to see examples with code, please click ***[List V2](https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG)*** @@ -12,7 +12,7 @@ If you want just those from Microsoft, please click ***[Microsoft](https://ignat If you want to see by category, please click ***[category](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples)*** or click any category below -[actor](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#actor) -[ai](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#ai) -[aop](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#aop) -[api](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#api) -[async](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#async) -[audit](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#audit) -[bitwise](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#bitwise) -[blazor](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#blazor) -[bool](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#bool) -[builder](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#builder) -[clone](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#clone) -[codetostring](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#codetostring) -[commandline](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#commandline) -[console](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#console) -[constructor](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#constructor) -[database](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#database) -[decorator](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#decorator) -[dependencyinjection](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#dependencyinjection) -[disposer](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#disposer) -[documentation](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#documentation) -[enhancementclass](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementclass) -[enhancementproject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) -[enum](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enum) -[equals](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#equals) -[filestocode](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#filestocode) -[functionalprogramming](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#functionalprogramming) -[hangfire](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#hangfire) -[idempotency](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#idempotency) -[interface](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#interface) -[linq](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#linq) -[mapper](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mapper) -[mcp](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mcp) -[mediator](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mediator) -[mixin](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mixin) -[mvc](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mvc) -[mvvm](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mvvm) -[optimizer](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#optimizer) -[primitiveobsession](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#primitiveobsession) -[profiler](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#profiler) -[rx](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#rx) -[serializer](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#serializer) -[signalr](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#signalr) -[statemachine](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#statemachine) -[templating](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#templating) -[tests](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#tests) -[validator](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#validator) -[winapi](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#winapi) - +[actor](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#actor) -[ai](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#ai) -[aop](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#aop) -[api](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#api) -[async](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#async) -[audit](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#audit) -[bitwise](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#bitwise) -[blazor](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#blazor) -[bool](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#bool) -[builder](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#builder) -[clone](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#clone) -[codetostring](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#codetostring) -[commandline](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#commandline) -[console](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#console) -[constructor](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#constructor) -[database](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#database) -[decorator](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#decorator) -[dependencyinjection](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#dependencyinjection) -[disposer](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#disposer) -[documentation](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#documentation) -[enhancementclass](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementclass) -[enhancementproject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) -[entityframework](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#entityframework) -[enum](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enum) -[equals](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#equals) -[filestocode](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#filestocode) -[functionalprogramming](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#functionalprogramming) -[hangfire](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#hangfire) -[idempotency](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#idempotency) -[interface](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#interface) -[linq](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#linq) -[mapper](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mapper) -[mcp](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mcp) -[mediator](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mediator) -[mixin](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mixin) -[mvc](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mvc) -[mvvm](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#mvvm) -[optimizer](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#optimizer) -[primitiveobsession](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#primitiveobsession) -[profiler](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#profiler) -[rx](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#rx) -[serializer](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#serializer) -[signalr](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#signalr) -[statemachine](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#statemachine) -[templating](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#templating) -[tests](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#tests) -[validator](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#validator) -[winapi](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#winapi) - ## If you have a Roslyn Source Code Generator, please create an issue. @@ -24,8 +24,30 @@ If you want to be notified each time I add a new RSCG example , please click htt ## Content -Those are the 277 Roslyn Source Code Generators that I have tested you can see and download source code example. +Those are the 278 Roslyn Source Code Generators that I have tested you can see and download source code example. ( including 16 from Microsoft ) +### 278. [Atulin.AutoDbSet](https://ignatandrei.github.io/RSCG_Examples/v2/docs/Atulin.AutoDbSet) , in the [EntityFramework](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#entityframework) category + +Generated on : 2026-08-18 => 18 August 2026 + +
+ Expand + + + +Author: Angius Atulin + +Package Description + +Nuget: [https://www.nuget.org/packages/Atulin.AutoDbSet/](https://www.nuget.org/packages/Atulin.AutoDbSet/) + + +Link: [https://ignatandrei.github.io/RSCG_Examples/v2/docs/Atulin.AutoDbSet](https://ignatandrei.github.io/RSCG_Examples/v2/docs/Atulin.AutoDbSet) + +Source: [https://github.com/Atulin/AutoDbSet](https://github.com/Atulin/AutoDbSet) + +
+ ### 277. [Bennewitz.Ninja.AutoVersioning](https://ignatandrei.github.io/RSCG_Examples/v2/docs/Bennewitz.Ninja.AutoVersioning) , in the [EnhancementProject](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementproject) category Generated on : 2026-07-04 => 04 July 2026 @@ -2023,7 +2045,7 @@ Source: [https://github.com/Georgiy-Petrov/StepwiseBuilderGenerator](https://git -### 187. [EntityLengths.Generator](https://ignatandrei.github.io/RSCG_Examples/v2/docs/EntityLengths.Generator) , in the [Database](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#database) category +### 187. [EntityLengths.Generator](https://ignatandrei.github.io/RSCG_Examples/v2/docs/EntityLengths.Generator) , in the [EntityFramework](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#entityframework) category Generated on : 2025-02-19 => 19 February 2025 diff --git a/later.md b/later.md index 736db985d..7c77384b0 100644 --- a/later.md +++ b/later.md @@ -1,6 +1,6 @@ # Just later -## Latest Update : 2026-07-04 => 04 July 2026 +## Latest Update : 2026-08-18 => 18 August 2026 diff --git a/v2/Generator/all.csv b/v2/Generator/all.csv index df9f2acc0..348301fff 100644 --- a/v2/Generator/all.csv +++ b/v2/Generator/all.csv @@ -185,7 +185,7 @@ Nr,Key,Source,Category 184,MockMe, https://github.com/connorivy/MockMe/,Tests 185,DependencyModules.SourceGenerator, https://github.com/ipjohnson/DependencyModules,DependencyInjection 186,RSCG_CompositeProvider, https://github.com/ignatandrei/RSCG_CompositeProvider,Interface -187,EntityLengths.Generator, https://github.com/TarasKovalenko/EntityLengths.Generator/,Database +187,EntityLengths.Generator, https://github.com/TarasKovalenko/EntityLengths.Generator/,EntityFramework 188,StepwiseBuilderGenerator, https://github.com/Georgiy-Petrov/StepwiseBuilderGenerator,Builder 189,MemberAccessor, https://github.com/usausa/member-accessor-generator,EnhancementClass 190,PMart.Enumeration, https://github.com/p-martinho/Enumeration,Enum @@ -276,3 +276,4 @@ Nr,Key,Source,Category 275,Porticle.Enumly, https://github.com/Machibuse/Porticle.Enumly,Enum 276,TinyBDD.MSTest, https://github.com/JerrettDavis/TinyBDD,Tests 277,Bennewitz.Ninja.AutoVersioning, https://github.com/JanusMael/Bennewitz.Ninja.AutoVersioning,EnhancementProject +278,Atulin.AutoDbSet, https://github.com/Atulin/AutoDbSet,EntityFramework diff --git a/v2/GeneratorData/Category.cs b/v2/GeneratorData/Category.cs index 93c7fed48..aed031285 100644 --- a/v2/GeneratorData/Category.cs +++ b/v2/GeneratorData/Category.cs @@ -50,5 +50,6 @@ public enum Category Idempotency=45, Documentation=46, Audit = 47, + EntityFramework = 48, } diff --git a/v2/RSCGExamplesData/GeneratorDataRec.json b/v2/RSCGExamplesData/GeneratorDataRec.json index 73af9bf9f..d6f25daea 100644 --- a/v2/RSCGExamplesData/GeneratorDataRec.json +++ b/v2/RSCGExamplesData/GeneratorDataRec.json @@ -1126,7 +1126,7 @@ }, { "ID":"EntityLengths.Generator", - "Category": 14, + "Category": 48, "dtStart": "2025-02-19T00:00:00", "show": true }, @@ -1678,5 +1678,11 @@ "Category": 1, "dtStart": "2026-07-04T00:00:00", "show": true + }, + { + "ID":"Atulin.AutoDbSet", + "Category": 48, + "dtStart": "2026-08-18T00:00:00", + "show": true } ] \ No newline at end of file diff --git a/v2/book/examples/Atulin.AutoDbSet.html b/v2/book/examples/Atulin.AutoDbSet.html new file mode 100644 index 000000000..1108509f4 --- /dev/null +++ b/v2/book/examples/Atulin.AutoDbSet.html @@ -0,0 +1,75 @@ + +

RSCG nr 278 : Atulin.AutoDbSet

+ +

Info

+Nuget : https://www.nuget.org/packages/Atulin.AutoDbSet/ + +

You can find more details at : https://github.com/Atulin/AutoDbSet

+ +

Author :Angius Atulin

+ +

Source: https://github.com/Atulin/AutoDbSet

+ +

About

+ +Generating DbSet properties for Entity Framework Core DbContext classes + +

+ How to use +

+

+ Add reference to the Atulin.AutoDbSet in the csproj +

+ + +

This was for me the starting code

+ +
+ I have coded the file Program.cs +
+ +
+ +
+ I have coded the file Project.cs +
+ +
+ +
+ I have coded the file DotNetStatsContext.cs +
+ +
+

And here are the generated files

+ +
+ The file generated is AutoDbSetAttribute.g.cs +
+ + +
+ The file generated is DbContextAttribute.g.cs +
+ + +
+ The file generated is DotNetStatsContext.g.cs +
+ + +

+ You can download the code and this page as pdf from + + https://ignatandrei.github.io/RSCG_Examples/v2/docs/Atulin.AutoDbSet + +

+ + +

+ You can see the whole list at + + https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG + +

+ diff --git a/v2/book/examples/Bennewitz.Ninja.AutoVersioning.html b/v2/book/examples/Bennewitz.Ninja.AutoVersioning.html new file mode 100644 index 000000000..914290750 --- /dev/null +++ b/v2/book/examples/Bennewitz.Ninja.AutoVersioning.html @@ -0,0 +1,58 @@ + +

RSCG nr 277 : Bennewitz.Ninja.AutoVersioning

+ +

Info

+Nuget : https://www.nuget.org/packages/Bennewitz.Ninja.AutoVersioning/ + +

You can find more details at : https://github.com/JanusMael/Bennewitz.Ninja.AutoVersioning

+ +

Author :Brian Bennewitz

+ +

Source: https://github.com/JanusMael/Bennewitz.Ninja.AutoVersioning

+ +

About

+ +Generating build version numbers for .NET projects + +

+ How to use +

+

+ Add reference to the Bennewitz.Ninja.AutoVersioning in the csproj +

+ + +

This was for me the starting code

+ +
+ I have coded the file Program.cs +
+ +
+

And here are the generated files

+ +
+ The file generated is AutoVersionedAssemblyInfo.g.cs +
+ + +
+ The file generated is DirectoryBuildInfo.g.cs +
+ + +

+ You can download the code and this page as pdf from + + https://ignatandrei.github.io/RSCG_Examples/v2/docs/Bennewitz.Ninja.AutoVersioning + +

+ + +

+ You can see the whole list at + + https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG + +

+ diff --git a/v2/book/list.html b/v2/book/list.html index 7b27cfa63..07f177f04 100644 --- a/v2/book/list.html +++ b/v2/book/list.html @@ -17,7 +17,7 @@

-This is the list of 276 RSCG with examples => +This is the list of 278 RSCG with examples =>

@@ -1130,6 +1130,14 @@

+ + + + + + + +
276 TinyBDD.MSTest
277Bennewitz.Ninja.AutoVersioning
278Atulin.AutoDbSet
diff --git a/v2/book/pandocHTML.yaml b/v2/book/pandocHTML.yaml index 9da9a4880..ad1a40133 100644 --- a/v2/book/pandocHTML.yaml +++ b/v2/book/pandocHTML.yaml @@ -290,6 +290,8 @@ input-files: - examples/Dirge.html - examples/Porticle.Enumly.html - examples/TinyBDD.MSTest.html +- examples/Bennewitz.Ninja.AutoVersioning.html +- examples/Atulin.AutoDbSet.html # or you may use input-file: with a single value # defaults: diff --git a/v2/docFind.json b/v2/docFind.json index d05932c5e..f8690632d 100644 --- a/v2/docFind.json +++ b/v2/docFind.json @@ -1117,7 +1117,7 @@ }, { "title": "EntityLengths.Generator", - "category": "Database", + "category": "EntityFramework", "href": "/RSCG_Examples/v2/docs/EntityLengths.Generator/", "body": "A C# source generator that automatically generates string length constants from Entity Framework configurations and data annotations." }, @@ -1654,5 +1654,17 @@ "category": "Tests", "href": "/RSCG_Examples/v2/docs/TinyBDD.MSTest/", "body": "Package Description" + }, + { + "title": "Bennewitz.Ninja.AutoVersioning", + "category": "EnhancementProject", + "href": "/RSCG_Examples/v2/docs/Bennewitz.Ninja.AutoVersioning/", + "body": "Assembly info incremental source generator." + }, + { + "title": "Atulin.AutoDbSet", + "category": "EntityFramework", + "href": "/RSCG_Examples/v2/docs/Atulin.AutoDbSet/", + "body": "Package Description" } ] \ No newline at end of file diff --git a/v2/rscg_examples/Atulin.AutoDbSet/description.json b/v2/rscg_examples/Atulin.AutoDbSet/description.json new file mode 100644 index 000000000..24dfcc53a --- /dev/null +++ b/v2/rscg_examples/Atulin.AutoDbSet/description.json @@ -0,0 +1,22 @@ +{ + "generator":{ + "name":"Atulin.AutoDbSet", + "nuget":[ + "https://www.nuget.org/packages/Atulin.AutoDbSet/" + ], + "link":"https://github.com/Atulin/AutoDbSet", + "author":"Angius Atulin", + "source":"https://github.com/Atulin/AutoDbSet" + }, + "data":{ + "goodFor":["Generating DbSet properties for Entity Framework Core DbContext classes"], + "csprojDemo":"EntityDemo.csproj", + "csFiles":["Program.cs","Project.cs","DotNetStatsContext.cs"], + "excludeDirectoryGenerated":[""], + "includeAdditionalFiles":[""] + }, + "links":{ + "blog":"", + "video":"" + } +} \ No newline at end of file diff --git a/v2/rscg_examples/Atulin.AutoDbSet/nuget.txt b/v2/rscg_examples/Atulin.AutoDbSet/nuget.txt new file mode 100644 index 000000000..882e74f60 --- /dev/null +++ b/v2/rscg_examples/Atulin.AutoDbSet/nuget.txt @@ -0,0 +1 @@ +Package Description \ No newline at end of file diff --git a/v2/rscg_examples/Atulin.AutoDbSet/readme.txt b/v2/rscg_examples/Atulin.AutoDbSet/readme.txt new file mode 100644 index 000000000..6794a260f --- /dev/null +++ b/v2/rscg_examples/Atulin.AutoDbSet/readme.txt @@ -0,0 +1,112 @@ +[![NuGet Version](https://img.shields.io/nuget/v/Atulin.AutoDbSet?style=for-the-badge)](https://www.nuget.org/packages/Atulin.AutoDbSet/) +![NuGet Downloads](https://img.shields.io/nuget/dt/Atulin.AutoDbSet?style=for-the-badge) +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Atulin/AutoDbSet/publish.yml?style=for-the-badge) +[![GitHub License](https://img.shields.io/github/license/Atulin/AutoDbSet?style=for-the-badge)](./LICENSE) + +# AutoDbSet + +Automagically add `DbSet`s to your `DbContext` + +## Usage + +Place `[AutoDbSet]` attribute on the database models you want to register... + +```cs +using AutoDbSetGenerators; + +namespace AutoDbSet.Demo; + +[AutoDbSet] +public class Person +{ + public required string Name { get; set; } + public required DateOnly Birthday { get; set; } + public required float Height { get; set; } +} +``` + +Place `[AutoDbContext]` attribute on your `DbContext` and make it `partial`... + +```cs +using AutoDbSetGenerators; +using Microsoft.EntityFrameworkCore; + +namespace AutoDbSet.Demo; + +[AutoDbContext] +public partial class MyCoolDbContext : DbContext +{ +} +``` + +And watch the magic happen! + +```cs +namespace AutoDbSet.Demo; + +[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +[global::System.CodeDom.Compiler.GeneratedCode("AutoDbSet", "2.0.0.0")] +public partial class MyCoolDbContext +{ + public required Microsoft.EntityFrameworkCore.DbSet Persons { get; init; } +} +``` + +## DbSet naming + +By default `AutoDbSet` will try to naively pluralize the names ([here's how](./AutoDbSet/NameHelpers.cs)). It does not, +therefore, work with verbs that have irregular plural form, nor does it work with non-English languages. + +You can, however, give the sets your own, custom name: + +```cs +[AutoDbSetGenerators.AutoDbSet(Name = "People")] +public class Person +{ + public required string Name { get; set; } + public required DateOnly Birthday { get; set; } + public required float Height { get; set; } +} +``` + +will generate + +```cs +namespace AutoDbSet.Demo; + +[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +[global::System.CodeDom.Compiler.GeneratedCode("AutoDbSet", "1.0.0.0")] +public partial class MyCoolDbContext +{ + public required Microsoft.EntityFrameworkCore.DbSet People { get; init; } +} +``` + +## Multiple `DbContext`s support + +You can relate a given class to a given `DbContext` using the `DbContext` property of the +`[AutoDbSet]` attribute: + +```cs +[AutoDbSetGenerators.AutoDbSet(DbContext = typeof(MyCoolerDbContext))] +public class CoolerPerson +{ + public required string Name { get; set; } + public required DateOnly Birthday { get; set; } + public required float Height { get; set; } + public bool IsCool { get; } = true; +} +``` + +Classes without an explicit `DbContext` will be registered to the single `DbContext` that +was not specified in any other `[AutoDbSet]` attribute. + +> [!IMPORTANT] +> There can only be a single default `DbContext` + +## ExpressiveSharp support + +AutoDbSet supports [ExpressiveSharp](https://github.com/EFNext/ExpressiveSharp) out of the box, +and generates `ExpressiveDbSet`s instead of `DbSet`s if it's available. \ No newline at end of file diff --git a/v2/rscg_examples/Atulin.AutoDbSet/src/.tours/Atulin.AutoDbSet.tour b/v2/rscg_examples/Atulin.AutoDbSet/src/.tours/Atulin.AutoDbSet.tour new file mode 100644 index 000000000..cee3a0dba --- /dev/null +++ b/v2/rscg_examples/Atulin.AutoDbSet/src/.tours/Atulin.AutoDbSet.tour @@ -0,0 +1,54 @@ + +{ + "$schema": "https://aka.ms/codetour-schema", + "title": "Atulin.AutoDbSet", + "steps": + [ + { + "file": "EntityDemo/EntityDemo.csproj", + "description": "First, we add Nuget [Atulin.AutoDbSet](https://www.nuget.org/packages/Atulin.AutoDbSet/) in csproj ", + "pattern": "Atulin.AutoDbSet" + } + + ,{ + "file": "EntityDemo/DotNetStatsContext.cs", + "description": "File DotNetStatsContext.cs ", + "pattern": "this is the code" + } + + ,{ + "file": "EntityDemo/Project.cs", + "description": "File Project.cs ", + "pattern": "this is the code" + } + + ,{ + "file": "EntityDemo/Program.cs", + "description": "File Program.cs \r\n>> dotnet run --project EntityDemo/EntityDemo.csproj ", + "pattern": "this is the code" + } + + + ,{ + "file": "EntityDemo/obj/GX/AutoDbSet/AutoDbSet.AutoDbSetIncrementalSourceGenerator/DotNetStatsContext.g.cs", + "description": "Generated File 3 from 3 : DotNetStatsContext.g.cs ", + "line": 1 + } + + ,{ + "file": "EntityDemo/obj/GX/AutoDbSet/AutoDbSet.AutoDbSetIncrementalSourceGenerator/DbContextAttribute.g.cs", + "description": "Generated File 2 from 3 : DbContextAttribute.g.cs ", + "line": 1 + } + + ,{ + "file": "EntityDemo/obj/GX/AutoDbSet/AutoDbSet.AutoDbSetIncrementalSourceGenerator/AutoDbSetAttribute.g.cs", + "description": "Generated File 1 from 3 : AutoDbSetAttribute.g.cs ", + "line": 1 + } + + ], + + "ref": "main" + +} \ No newline at end of file diff --git a/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo.sln b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo.sln new file mode 100644 index 000000000..29ae3a882 --- /dev/null +++ b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35806.99 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityDemo", "EntityDemo\EntityDemo.csproj", "{8E781946-11BC-4A8C-857F-E1770565823D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8E781946-11BC-4A8C-857F-E1770565823D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E781946-11BC-4A8C-857F-E1770565823D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E781946-11BC-4A8C-857F-E1770565823D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E781946-11BC-4A8C-857F-E1770565823D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F93AFAB4-9779-49B1-A381-7C4845EA2ED1} + EndGlobalSection +EndGlobal diff --git a/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/DotNetStatsContext.cs b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/DotNetStatsContext.cs new file mode 100644 index 000000000..cc41c3b6d --- /dev/null +++ b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/DotNetStatsContext.cs @@ -0,0 +1,45 @@ + +using System.Diagnostics.CodeAnalysis; + +namespace Stats.Database; + +[AutoDbSetGenerators.AutoDbContext] +public partial class DotNetStatsContext : DbContext +{ + [SetsRequiredMembers] + internal DotNetStatsContext() : base() { + Stars = Set(); + Projects = Set(); + } + [SetsRequiredMembers] + public DotNetStatsContext(DbContextOptions options) + : base(options) + { + Stars = Set(); + Projects = Set(); + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + //entity.ToTable("Project"); + + entity.Property(e => e.Id);//.HasColumnName("ID"); + entity.Property(e => e.Description).HasMaxLength(500); + entity.Property(e => e.Name).HasMaxLength(50); + entity.Property(e => e.SourceCodeUrl).HasMaxLength(50); + }); + + modelBuilder.Entity(entity => + { + // entity.Property(e => e.Id) + // .HasColumnName("ID"); + // entity.Property(e => e.Idproject).HasColumnName("IDProject"); + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/EntityDemo.csproj b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/EntityDemo.csproj new file mode 100644 index 000000000..4a664a649 --- /dev/null +++ b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/EntityDemo.csproj @@ -0,0 +1,23 @@ + + + + Exe + net10.0 + enable + enable + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + true + $(BaseIntermediateOutputPath)\GX + + diff --git a/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/Program.cs b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/Program.cs new file mode 100644 index 000000000..0cfdd67e7 --- /dev/null +++ b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/Program.cs @@ -0,0 +1,10 @@ +using Microsoft.EntityFrameworkCore; +using System.Threading.Tasks; + +Console.WriteLine("Hello, World!"); +DbContextOptionsBuilder optionsBuilder = new(); +optionsBuilder.UseInMemoryDatabase("StatsDatabase"); +var cnt = new DotNetStatsContext(optionsBuilder.Options); +await cnt.Database.EnsureCreatedAsync(); +Console.WriteLine("Database created"); +Console.WriteLine(cnt.Projects.Count()); diff --git a/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/Project.cs b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/Project.cs new file mode 100644 index 000000000..0c77981eb --- /dev/null +++ b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/Project.cs @@ -0,0 +1,13 @@ +namespace Stats.Database; + +[AutoDbSetGenerators.AutoDbSet] +public partial class Project +{ + public long Id { get; set; } + + public string Name { get; set; } = null!; + + public string SourceCodeUrl { get; set; } = null!; + + public string? Description { get; set; } +} diff --git a/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/Star.cs b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/Star.cs new file mode 100644 index 000000000..0beabfdbb --- /dev/null +++ b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/Star.cs @@ -0,0 +1,13 @@ +namespace Stats.Database; + +[AutoDbSetGenerators.AutoDbSet] +public partial class Star +{ + public long Id { get; set; } + + public long Idproject { get; set; } + + public int Count { get; set; } + + public DateOnly DateRecording { get; set; } +} diff --git a/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/globals.cs b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/globals.cs new file mode 100644 index 000000000..0d211d114 --- /dev/null +++ b/v2/rscg_examples/Atulin.AutoDbSet/src/EntityDemo/globals.cs @@ -0,0 +1,2 @@ +global using Microsoft.EntityFrameworkCore; +global using Stats.Database; diff --git a/v2/rscg_examples/Atulin.AutoDbSet/video.json b/v2/rscg_examples/Atulin.AutoDbSet/video.json new file mode 100644 index 000000000..7203625af --- /dev/null +++ b/v2/rscg_examples/Atulin.AutoDbSet/video.json @@ -0,0 +1,39 @@ +{ + "scriptName": "Atulin.AutoDbSet", + "steps": +[ + {"typeStep":"exec","arg":"clipchamp.exe launch"}, + {"typeStep":"text","arg": "Welcome to Roslyn Examples"}, + {"typeStep":"text","arg":"If you want to see more examples , see List Of RSCG"}, + {"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG"}, + {"typeStep":"text","arg": "My name is Andrei Ignat and I am deeply fond of Roslyn Source Code Generator. "}, + +{"typeStep":"text","arg": "Today I will present Atulin.AutoDbSet . Generating DbSet properties for Entity Framework Core DbContext classes ."}, +{"typeStep":"browser","arg":"https://www.nuget.org/packages/Atulin.AutoDbSet/"}, +{"typeStep":"text","arg": "The whole example is here"}, +{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/Atulin.AutoDbSet"}, +{"typeStep":"text","arg": "You can download the code from here"}, +{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/Atulin.AutoDbSet#download-example-net--c-"}, +{"typeStep":"text","arg":"Here is the code downloaded "}, +{"typeStep":"exec","arg":"explorer.exe /select,D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\Atulin.AutoDbSet\\src\\EntityDemo.sln"}, +{"typeStep":"text","arg": "So , let's start the project with Visual Studio Code "}, +{"typeStep":"stepvscode","arg": "-n D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\Atulin.AutoDbSet\\src"}, + +{"typeStep":"text","arg": "To use it ,you will put the Nuget Atulin.AutoDbSet into the csproj "}, + +{"typeStep":"stepvscode","arg": "-r -g D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\Atulin.AutoDbSet\\src\\EntityDemo\\EntityDemo.csproj"}, + +{"typeStep":"text","arg": "And now I will show you an example of using Atulin.AutoDbSet"}, + +{"typeStep":"hide","arg": "now execute the tour in VSCode"}, +{"typeStep":"tour", "arg": "src/.tours/"}, +{"typeStep":"text","arg":" And I will execute the project"}, +{"typeStep":"showproj", "arg":"EntityDemo.csproj"}, +{"typeStep":"text","arg":" This concludes the project"}, +{"typeStep":"waitseconds","arg":"30"}, +{"typeStep":"text","arg": "Remember, you can download the code from here"}, +{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/Atulin.AutoDbSet#download-example-net--c-", +SpeakTest=" "}, +{"typeStep":"waitseconds","arg":"30"}, +] +} diff --git a/v2/rscg_examples_site/docs/Authors/Angius_Atulin.md b/v2/rscg_examples_site/docs/Authors/Angius_Atulin.md new file mode 100644 index 000000000..de05d1750 --- /dev/null +++ b/v2/rscg_examples_site/docs/Authors/Angius_Atulin.md @@ -0,0 +1,7 @@ +# Author : Angius Atulin + +Number RSCG: 1 + + + 1 [Atulin.AutoDbSet](/docs/Atulin.AutoDbSet) [![Nuget](https://img.shields.io/nuget/dt/Atulin.AutoDbSet?label=Atulin.AutoDbSet)](https://www.nuget.org/packages/Atulin.AutoDbSet/) ![GitHub Repo stars](https://img.shields.io/github/stars/Atulin/AutoDbSet?style=social) 2026-08-18 + diff --git a/v2/rscg_examples_site/docs/Categories/Database.md b/v2/rscg_examples_site/docs/Categories/Database.md index 7ce411cf1..b2378e1f7 100644 --- a/v2/rscg_examples_site/docs/Categories/Database.md +++ b/v2/rscg_examples_site/docs/Categories/Database.md @@ -1,6 +1,6 @@

Database

-Number RSCG: 9 +Number RSCG: 8 1 [AlephMapper](/docs/AlephMapper) [![Nuget](https://img.shields.io/nuget/dt/AlephMapper?label=AlephMapper)](https://www.nuget.org/packages/AlephMapper/) ![GitHub Repo stars](https://img.shields.io/github/stars/Raffinert/AlephMapper?style=social) 2026-06-29 @@ -8,15 +8,13 @@ Number RSCG: 9 3 [Dapper.AOT](/docs/Dapper.AOT) [![Nuget](https://img.shields.io/nuget/dt/Dapper.AOT?label=Dapper.AOT)](https://www.nuget.org/packages/Dapper.AOT/) ![GitHub Repo stars](https://img.shields.io/github/stars/DapperLib/DapperAOT?style=social) 2024-12-02 - 4 [EntityLengths.Generator](/docs/EntityLengths.Generator) [![Nuget](https://img.shields.io/nuget/dt/EntityLengths.Generator?label=EntityLengths.Generator)](https://www.nuget.org/packages/EntityLengths.Generator/) ![GitHub Repo stars](https://img.shields.io/github/stars/TarasKovalenko/EntityLengths.Generator?style=social) 2025-02-19 + 4 [Facet.Search](/docs/Facet.Search) [![Nuget](https://img.shields.io/nuget/dt/Facet.Search?label=Facet.Search)](https://www.nuget.org/packages/Facet.Search/) ![GitHub Repo stars](https://img.shields.io/github/stars/Tim-Maes/Facet.Search?style=social) 2025-12-17 - 5 [Facet.Search](/docs/Facet.Search) [![Nuget](https://img.shields.io/nuget/dt/Facet.Search?label=Facet.Search)](https://www.nuget.org/packages/Facet.Search/) ![GitHub Repo stars](https://img.shields.io/github/stars/Tim-Maes/Facet.Search?style=social) 2025-12-17 + 5 [Finch.Generators](/docs/Finch.Generators) [![Nuget](https://img.shields.io/nuget/dt/Finch.Generators?label=Finch.Generators)](https://www.nuget.org/packages/Finch.Generators/) ![GitHub Repo stars](https://img.shields.io/github/stars/ivmazurenko/finch?style=social) 2025-08-10 - 6 [Finch.Generators](/docs/Finch.Generators) [![Nuget](https://img.shields.io/nuget/dt/Finch.Generators?label=Finch.Generators)](https://www.nuget.org/packages/Finch.Generators/) ![GitHub Repo stars](https://img.shields.io/github/stars/ivmazurenko/finch?style=social) 2025-08-10 + 6 [Gedaq](/docs/Gedaq) [![Nuget](https://img.shields.io/nuget/dt/Gedaq?label=Gedaq)](https://www.nuget.org/packages/Gedaq/) ![GitHub Repo stars](https://img.shields.io/github/stars/SoftStoneDevelop/Gedaq?style=social) 2023-07-29 - 7 [Gedaq](/docs/Gedaq) [![Nuget](https://img.shields.io/nuget/dt/Gedaq?label=Gedaq)](https://www.nuget.org/packages/Gedaq/) ![GitHub Repo stars](https://img.shields.io/github/stars/SoftStoneDevelop/Gedaq?style=social) 2023-07-29 + 7 [TableStorage](/docs/TableStorage) [![Nuget](https://img.shields.io/nuget/dt/TableStorage?label=TableStorage)](https://www.nuget.org/packages/TableStorage/) ![GitHub Repo stars](https://img.shields.io/github/stars/StevenThuriot/TableStorage?style=social) 2024-06-01 - 8 [TableStorage](/docs/TableStorage) [![Nuget](https://img.shields.io/nuget/dt/TableStorage?label=TableStorage)](https://www.nuget.org/packages/TableStorage/) ![GitHub Repo stars](https://img.shields.io/github/stars/StevenThuriot/TableStorage?style=social) 2024-06-01 - - 9 [Unflat](/docs/Unflat) [![Nuget](https://img.shields.io/nuget/dt/Unflat?label=Unflat)](https://www.nuget.org/packages/Unflat/) ![GitHub Repo stars](https://img.shields.io/github/stars/pstlnce/unflat?style=social) 2025-08-18 + 8 [Unflat](/docs/Unflat) [![Nuget](https://img.shields.io/nuget/dt/Unflat?label=Unflat)](https://www.nuget.org/packages/Unflat/) ![GitHub Repo stars](https://img.shields.io/github/stars/pstlnce/unflat?style=social) 2025-08-18 \ No newline at end of file diff --git a/v2/rscg_examples_site/docs/Categories/EntityFramework.md b/v2/rscg_examples_site/docs/Categories/EntityFramework.md new file mode 100644 index 000000000..0ece30daf --- /dev/null +++ b/v2/rscg_examples_site/docs/Categories/EntityFramework.md @@ -0,0 +1,8 @@ +

EntityFramework

+ +Number RSCG: 2 + + 1 [Atulin.AutoDbSet](/docs/Atulin.AutoDbSet) [![Nuget](https://img.shields.io/nuget/dt/Atulin.AutoDbSet?label=Atulin.AutoDbSet)](https://www.nuget.org/packages/Atulin.AutoDbSet/) ![GitHub Repo stars](https://img.shields.io/github/stars/Atulin/AutoDbSet?style=social) 2026-08-18 + + 2 [EntityLengths.Generator](/docs/EntityLengths.Generator) [![Nuget](https://img.shields.io/nuget/dt/EntityLengths.Generator?label=EntityLengths.Generator)](https://www.nuget.org/packages/EntityLengths.Generator/) ![GitHub Repo stars](https://img.shields.io/github/stars/TarasKovalenko/EntityLengths.Generator?style=social) 2025-02-19 + \ No newline at end of file diff --git a/v2/rscg_examples_site/docs/Categories/_PrimitiveDatabase.mdx b/v2/rscg_examples_site/docs/Categories/_PrimitiveDatabase.mdx index f769e62ec..71c94dfc9 100644 --- a/v2/rscg_examples_site/docs/Categories/_PrimitiveDatabase.mdx +++ b/v2/rscg_examples_site/docs/Categories/_PrimitiveDatabase.mdx @@ -6,17 +6,15 @@ 3 [Dapper.AOT](/docs/Dapper.AOT) [![Nuget](https://img.shields.io/nuget/dt/Dapper.AOT?label=Dapper.AOT)](https://www.nuget.org/packages/Dapper.AOT/) ![GitHub Repo stars](https://img.shields.io/github/stars/DapperLib/DapperAOT?style=social) 2024-12-02 - 4 [EntityLengths.Generator](/docs/EntityLengths.Generator) [![Nuget](https://img.shields.io/nuget/dt/EntityLengths.Generator?label=EntityLengths.Generator)](https://www.nuget.org/packages/EntityLengths.Generator/) ![GitHub Repo stars](https://img.shields.io/github/stars/TarasKovalenko/EntityLengths.Generator?style=social) 2025-02-19 + 4 [Facet.Search](/docs/Facet.Search) [![Nuget](https://img.shields.io/nuget/dt/Facet.Search?label=Facet.Search)](https://www.nuget.org/packages/Facet.Search/) ![GitHub Repo stars](https://img.shields.io/github/stars/Tim-Maes/Facet.Search?style=social) 2025-12-17 - 5 [Facet.Search](/docs/Facet.Search) [![Nuget](https://img.shields.io/nuget/dt/Facet.Search?label=Facet.Search)](https://www.nuget.org/packages/Facet.Search/) ![GitHub Repo stars](https://img.shields.io/github/stars/Tim-Maes/Facet.Search?style=social) 2025-12-17 + 5 [Finch.Generators](/docs/Finch.Generators) [![Nuget](https://img.shields.io/nuget/dt/Finch.Generators?label=Finch.Generators)](https://www.nuget.org/packages/Finch.Generators/) ![GitHub Repo stars](https://img.shields.io/github/stars/ivmazurenko/finch?style=social) 2025-08-10 - 6 [Finch.Generators](/docs/Finch.Generators) [![Nuget](https://img.shields.io/nuget/dt/Finch.Generators?label=Finch.Generators)](https://www.nuget.org/packages/Finch.Generators/) ![GitHub Repo stars](https://img.shields.io/github/stars/ivmazurenko/finch?style=social) 2025-08-10 + 6 [Gedaq](/docs/Gedaq) [![Nuget](https://img.shields.io/nuget/dt/Gedaq?label=Gedaq)](https://www.nuget.org/packages/Gedaq/) ![GitHub Repo stars](https://img.shields.io/github/stars/SoftStoneDevelop/Gedaq?style=social) 2023-07-29 - 7 [Gedaq](/docs/Gedaq) [![Nuget](https://img.shields.io/nuget/dt/Gedaq?label=Gedaq)](https://www.nuget.org/packages/Gedaq/) ![GitHub Repo stars](https://img.shields.io/github/stars/SoftStoneDevelop/Gedaq?style=social) 2023-07-29 + 7 [TableStorage](/docs/TableStorage) [![Nuget](https://img.shields.io/nuget/dt/TableStorage?label=TableStorage)](https://www.nuget.org/packages/TableStorage/) ![GitHub Repo stars](https://img.shields.io/github/stars/StevenThuriot/TableStorage?style=social) 2024-06-01 - 8 [TableStorage](/docs/TableStorage) [![Nuget](https://img.shields.io/nuget/dt/TableStorage?label=TableStorage)](https://www.nuget.org/packages/TableStorage/) ![GitHub Repo stars](https://img.shields.io/github/stars/StevenThuriot/TableStorage?style=social) 2024-06-01 - - 9 [Unflat](/docs/Unflat) [![Nuget](https://img.shields.io/nuget/dt/Unflat?label=Unflat)](https://www.nuget.org/packages/Unflat/) ![GitHub Repo stars](https://img.shields.io/github/stars/pstlnce/unflat?style=social) 2025-08-18 + 8 [Unflat](/docs/Unflat) [![Nuget](https://img.shields.io/nuget/dt/Unflat?label=Unflat)](https://www.nuget.org/packages/Unflat/) ![GitHub Repo stars](https://img.shields.io/github/stars/pstlnce/unflat?style=social) 2025-08-18 ### See category diff --git a/v2/rscg_examples_site/docs/Categories/_PrimitiveEntityFramework.mdx b/v2/rscg_examples_site/docs/Categories/_PrimitiveEntityFramework.mdx new file mode 100644 index 000000000..74d0807d1 --- /dev/null +++ b/v2/rscg_examples_site/docs/Categories/_PrimitiveEntityFramework.mdx @@ -0,0 +1,9 @@ +### Category "EntityFramework" has the following generators: + + 1 [Atulin.AutoDbSet](/docs/Atulin.AutoDbSet) [![Nuget](https://img.shields.io/nuget/dt/Atulin.AutoDbSet?label=Atulin.AutoDbSet)](https://www.nuget.org/packages/Atulin.AutoDbSet/) ![GitHub Repo stars](https://img.shields.io/github/stars/Atulin/AutoDbSet?style=social) 2026-08-18 + + 2 [EntityLengths.Generator](/docs/EntityLengths.Generator) [![Nuget](https://img.shields.io/nuget/dt/EntityLengths.Generator?label=EntityLengths.Generator)](https://www.nuget.org/packages/EntityLengths.Generator/) ![GitHub Repo stars](https://img.shields.io/github/stars/TarasKovalenko/EntityLengths.Generator?style=social) 2025-02-19 + +### See category + +[EntityFramework](/docs/Categories/EntityFramework) diff --git a/v2/rscg_examples_site/docs/RSCG-Examples/Atulin.AutoDbSet.md b/v2/rscg_examples_site/docs/RSCG-Examples/Atulin.AutoDbSet.md new file mode 100644 index 000000000..121907df7 --- /dev/null +++ b/v2/rscg_examples_site/docs/RSCG-Examples/Atulin.AutoDbSet.md @@ -0,0 +1,435 @@ +--- +sidebar_position: 2780 +title: 278 - Atulin.AutoDbSet +description: Generating DbSet properties for Entity Framework Core DbContext classes +slug: /Atulin.AutoDbSet +--- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import TOCInline from '@theme/TOCInline'; +import SameCategory from '../Categories/_PrimitiveEntityFramework.mdx'; + +# Atulin.AutoDbSet by Angius Atulin + + + + +## NuGet / site data +[![Nuget](https://img.shields.io/nuget/dt/Atulin.AutoDbSet?label=Atulin.AutoDbSet)](https://www.nuget.org/packages/Atulin.AutoDbSet/) +[![GitHub last commit](https://img.shields.io/github/last-commit/Atulin/AutoDbSet?label=updated)](https://github.com/Atulin/AutoDbSet) +![GitHub Repo stars](https://img.shields.io/github/stars/Atulin/AutoDbSet?style=social) + +## Details + +### Info +:::info + +Name: **Atulin.AutoDbSet** + +Package Description + +Author: Angius Atulin + +NuGet: +*https://www.nuget.org/packages/Atulin.AutoDbSet/* + + +You can find more details at https://github.com/Atulin/AutoDbSet + +Source: https://github.com/Atulin/AutoDbSet + +::: + +### Author +:::note +Angius Atulin +![Alt text](https://github.com/Atulin.png) +::: + +## Original Readme +:::note + +[![NuGet Version](https://img.shields.io/nuget/v/Atulin.AutoDbSet?style=for-the-badge)](https://www.nuget.org/packages/Atulin.AutoDbSet/) +![NuGet Downloads](https://img.shields.io/nuget/dt/Atulin.AutoDbSet?style=for-the-badge) +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Atulin/AutoDbSet/publish.yml?style=for-the-badge) +[![GitHub License](https://img.shields.io/github/license/Atulin/AutoDbSet?style=for-the-badge)](https://github.com/Atulin/AutoDbSet/LICENSE) + +### AutoDbSet + +Automagically add `DbSet`s to your `DbContext` + +###### Usage + +Place `[AutoDbSet]` attribute on the database models you want to register... + +```cs +using AutoDbSetGenerators; + +namespace AutoDbSet.Demo; + +[AutoDbSet] +public class Person +{ + public required string Name \{ get; set; } + public required DateOnly Birthday \{ get; set; } + public required float Height \{ get; set; } +} +``` + +Place `[AutoDbContext]` attribute on your `DbContext` and make it `partial`... + +```cs +using AutoDbSetGenerators; +using Microsoft.EntityFrameworkCore; + +namespace AutoDbSet.Demo; + +[AutoDbContext] +public partial class MyCoolDbContext : DbContext +{ +} +``` + +And watch the magic happen! + +```cs +namespace AutoDbSet.Demo; + +[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +[global::System.CodeDom.Compiler.GeneratedCode("AutoDbSet", "2.0.0.0")] +public partial class MyCoolDbContext +{ + public required Microsoft.EntityFrameworkCore.DbSet Persons \{ get; init; } +} +``` + +###### DbSet naming + +By default `AutoDbSet` will try to naively pluralize the names ([here's how](https://github.com/Atulin/AutoDbSet/AutoDbSet/NameHelpers.cs)). It does not, +therefore, work with verbs that have irregular plural form, nor does it work with non-English languages. + +You can, however, give the sets your own, custom name: + +```cs +[AutoDbSetGenerators.AutoDbSet(Name = "People")] +public class Person +{ + public required string Name \{ get; set; } + public required DateOnly Birthday \{ get; set; } + public required float Height \{ get; set; } +} +``` + +will generate + +```cs +namespace AutoDbSet.Demo; + +[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +[global::System.CodeDom.Compiler.GeneratedCode("AutoDbSet", "1.0.0.0")] +public partial class MyCoolDbContext +{ + public required Microsoft.EntityFrameworkCore.DbSet People \{ get; init; } +} +``` + +###### Multiple `DbContext`s support + +You can relate a given class to a given `DbContext` using the `DbContext` property of the +`[AutoDbSet]` attribute: + +```cs +[AutoDbSetGenerators.AutoDbSet(DbContext = typeof(MyCoolerDbContext))] +public class CoolerPerson +{ + public required string Name \{ get; set; } + public required DateOnly Birthday \{ get; set; } + public required float Height \{ get; set; } + public bool IsCool \{ get; \} = true; +} +``` + +Classes without an explicit `DbContext` will be registered to the single `DbContext` that +was not specified in any other `[AutoDbSet]` attribute. + +> [!IMPORTANT] +> There can only be a single default `DbContext` + +###### ExpressiveSharp support + +AutoDbSet supports [ExpressiveSharp](https://github.com/EFNext/ExpressiveSharp) out of the box, +and generates `ExpressiveDbSet`s instead of `DbSet`s if it's available. + +::: + +### About +:::note + +Generating DbSet properties for Entity Framework Core DbContext classes + + +::: + +## How to use + +### Example (source csproj, source files) + + + + + +This is the CSharp Project that references **Atulin.AutoDbSet** +```xml showLineNumbers {10} + + + + Exe + net10.0 + enable + enable + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + true + $(BaseIntermediateOutputPath)\GX + + + +``` + + + + + + This is the use of **Atulin.AutoDbSet** in *Program.cs* + +```csharp showLineNumbers +using Microsoft.EntityFrameworkCore; +using System.Threading.Tasks; + +Console.WriteLine("Hello, World!"); +DbContextOptionsBuilder optionsBuilder = new(); +optionsBuilder.UseInMemoryDatabase("StatsDatabase"); +var cnt = new DotNetStatsContext(optionsBuilder.Options); +await cnt.Database.EnsureCreatedAsync(); +Console.WriteLine("Database created"); +Console.WriteLine(cnt.Projects.Count()); + +``` + + + + + This is the use of **Atulin.AutoDbSet** in *Project.cs* + +```csharp showLineNumbers +namespace Stats.Database; + +[AutoDbSetGenerators.AutoDbSet] +public partial class Project +{ + public long Id \{ get; set; } + + public string Name \{ get; set; \} = null!; + + public string SourceCodeUrl \{ get; set; \} = null!; + + public string? Description \{ get; set; } +} + +``` + + + + + This is the use of **Atulin.AutoDbSet** in *DotNetStatsContext.cs* + +```csharp showLineNumbers + +using System.Diagnostics.CodeAnalysis; + +namespace Stats.Database; + +[AutoDbSetGenerators.AutoDbContext] +public partial class DotNetStatsContext : DbContext +{ + [SetsRequiredMembers] + internal DotNetStatsContext() : base() { + Stars = Set(); + Projects = Set(); + } + [SetsRequiredMembers] + public DotNetStatsContext(DbContextOptions options) + : base(options) + { + Stars = Set(); + Projects = Set(); + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + //entity.ToTable("Project"); + + entity.Property(e => e.Id);//.HasColumnName("ID"); + entity.Property(e => e.Description).HasMaxLength(500); + entity.Property(e => e.Name).HasMaxLength(50); + entity.Property(e => e.SourceCodeUrl).HasMaxLength(50); + }); + + modelBuilder.Entity(entity => + { + // entity.Property(e => e.Id) + // .HasColumnName("ID"); + // entity.Property(e => e.Idproject).HasColumnName("IDProject"); + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} + +``` + + + + +### Generated Files + +Those are taken from $(BaseIntermediateOutputPath)\GX + + + + +```csharp showLineNumbers +//------------------------------------------------------------------------------ +// +// This code was generated by a tool AutoDbSet. +// Runtime Version: 2.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +#nullable enable +namespace AutoDbSetGenerators; + +/// +/// Marks the class to generate a DbSet out of +/// +[global::System.AttributeUsage(System.AttributeTargets.Class)] +[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +[global::System.CodeDom.Compiler.GeneratedCode("AutoDbSet", "2.0.0.0")] +public sealed class AutoDbSetAttribute : global::System.Attribute +{ + /// + /// Sets name to be used in the database. + /// + public string? Name \{ get; set; } + + /// + /// DbContext this DbSet should belong to + /// + public global::System.Type? DbContext \{ get; set; } +} +#nullable restore +``` + + + + +```csharp showLineNumbers +//------------------------------------------------------------------------------ +// +// This code was generated by a tool AutoDbSet. +// Runtime Version: 2.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +#nullable enable +namespace AutoDbSetGenerators; + +/// +/// Marks the DbContext to generate DbSets into +/// +[global::System.AttributeUsage(System.AttributeTargets.Class)] +[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +[global::System.CodeDom.Compiler.GeneratedCode("AutoDbSet", "2.0.0.0")] +public sealed class AutoDbContextAttribute : global::System.Attribute +{} +#nullable restore +``` + + + + +```csharp showLineNumbers +//------------------------------------------------------------------------------ +// +// This code was generated by a tool AutoDbSet. +// Runtime Version: 2.0.0.0 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ +#nullable enable + +namespace Stats.Database; + +[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute] +[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] +[global::System.CodeDom.Compiler.GeneratedCode("AutoDbSet", "2.0.0.0")] +public partial class DotNetStatsContext +{ + public required Microsoft.EntityFrameworkCore.DbSet Projects \{ get; init; } + public required Microsoft.EntityFrameworkCore.DbSet Stars \{ get; init; } + +} +#nullable restore +``` + + + + +## Useful + +### Download Example (.NET C#) + +:::tip + +[Download Example project Atulin.AutoDbSet ](/sources/Atulin.AutoDbSet.zip) + +::: + + +### Share Atulin.AutoDbSet + + + +https://ignatandrei.github.io/RSCG_Examples/v2/docs/Atulin.AutoDbSet + + + diff --git a/v2/rscg_examples_site/docs/RSCG-Examples/index.md b/v2/rscg_examples_site/docs/RSCG-Examples/index.md index 797c717cc..8c8bb8058 100644 --- a/v2/rscg_examples_site/docs/RSCG-Examples/index.md +++ b/v2/rscg_examples_site/docs/RSCG-Examples/index.md @@ -1,7 +1,7 @@ --- sidebar_position: 30 -title: 277 RSCG list by category -description: 277 RSCG list by category +title: 278 RSCG list by category +description: 278 RSCG list by category slug: /rscg-examples --- @@ -393,7 +393,7 @@ import DocCardList from '@theme/DocCardList'; ## Database
- Expand Database =>examples:9 + Expand Database =>examples:8 @@ -417,11 +417,6 @@ import DocCardList from '@theme/DocCardList'; -[EntityLengths.Generator](/docs/EntityLengths.Generator) - - - - [Finch.Generators](/docs/Finch.Generators) @@ -839,6 +834,23 @@ import DocCardList from '@theme/DocCardList';
+## EntityFramework +
+ + Expand EntityFramework =>examples:2 + + + +[EntityLengths.Generator](/docs/EntityLengths.Generator) + + + + +[Atulin.AutoDbSet](/docs/Atulin.AutoDbSet) + +
+ + ## Enum
@@ -1847,8 +1859,6 @@ flowchart LR; Database--> Dapper.AOT((Dapper.AOT)) - Database--> EntityLengths.Generator((EntityLengths.Generator)) - Database--> Finch.Generators((Finch.Generators)) Database--> Unflat((Unflat)) @@ -1999,6 +2009,10 @@ flowchart LR; EnhancementProject--> Bennewitz.Ninja.AutoVersioning((Bennewitz.Ninja.AutoVersioning)) + EntityFramework--> EntityLengths.Generator((EntityLengths.Generator)) + + EntityFramework--> Atulin.AutoDbSet((Atulin.AutoDbSet)) + Enum--> NetEscapades.EnumGenerators((NetEscapades.EnumGenerators)) Enum--> EnumClass((EnumClass)) diff --git a/v2/rscg_examples_site/docs/about.md b/v2/rscg_examples_site/docs/about.md index cb2cbce29..105ed1587 100644 --- a/v2/rscg_examples_site/docs/about.md +++ b/v2/rscg_examples_site/docs/about.md @@ -6,7 +6,7 @@ title: About ## Content You will find here code examples -of 277 Roslyn Source Code Generator (RSCG) +of 278 Roslyn Source Code Generator (RSCG) that can be useful for you. That means, you will write more elegant and concise code - even if the generators code is not always nice to look. ## Are those examples ready for production? diff --git a/v2/rscg_examples_site/docs/indexRSCG.md b/v2/rscg_examples_site/docs/indexRSCG.md index 2010727bb..973078e5b 100644 --- a/v2/rscg_examples_site/docs/indexRSCG.md +++ b/v2/rscg_examples_site/docs/indexRSCG.md @@ -7,9 +7,9 @@ slug: /List-of-RSCG import useBaseUrl from '@docusaurus/useBaseUrl'; -## 277 RSCG with examples in descending chronological order +## 278 RSCG with examples in descending chronological order -This is the list of 277 ( 16 from Microsoft) RSCG with examples +This is the list of 278 ( 16 from Microsoft) RSCG with examples [See by category](/docs/rscg-examples) [See as json](/exports/RSCG.json) [See as Excel](/exports/RSCG.xlsx) @@ -20,6 +20,7 @@ This is the list of 277 ( 16 from Microsoft) RSCG with examples | No | Name | Date | Category | | --------- | ----- | ---- | -------- | +|278| [Atulin.AutoDbSet by Angius Atulin ](/docs/Atulin.AutoDbSet)|2026-08-18 => 18 August 2026 | [EntityFramework](/docs/Categories/EntityFramework) | |277| [Bennewitz.Ninja.AutoVersioning by Brian Bennewitz ](/docs/Bennewitz.Ninja.AutoVersioning)|2026-07-04 => 04 July 2026 | [EnhancementProject](/docs/Categories/EnhancementProject) | |276| [TinyBDD.MSTest by Jerrett Davis ](/docs/TinyBDD.MSTest)|2026-07-03 => 03 July 2026 | [Tests](/docs/Categories/Tests) | |275| [Porticle.Enumly by Carsten Jendro ](/docs/Porticle.Enumly)|2026-07-02 => 02 July 2026 | [Enum](/docs/Categories/Enum) | @@ -110,7 +111,7 @@ This is the list of 277 ( 16 from Microsoft) RSCG with examples |190| [PMart.Enumeration by Martinho ](/docs/PMart.Enumeration)|2025-03-25 => 25 March 2025 | [Enum](/docs/Categories/Enum) | |189| [MemberAccessor by Yamaokuno ](/docs/MemberAccessor)|2025-03-24 => 24 March 2025 | [EnhancementClass](/docs/Categories/EnhancementClass) | |188| [StepwiseBuilderGenerator by Georgiy Petrov ](/docs/StepwiseBuilderGenerator)|2025-03-23 => 23 March 2025 | [Builder](/docs/Categories/Builder) | -|187| [EntityLengths.Generator by Taras Kovalenko ](/docs/EntityLengths.Generator)|2025-02-19 => 19 February 2025 | [Database](/docs/Categories/Database) | +|187| [EntityLengths.Generator by Taras Kovalenko ](/docs/EntityLengths.Generator)|2025-02-19 => 19 February 2025 | [EntityFramework](/docs/Categories/EntityFramework) | |186| [RSCG_CompositeProvider by Ignat Andrei ](/docs/RSCG_CompositeProvider)|2025-02-18 => 18 February 2025 | [Interface](/docs/Categories/Interface) | |185| [DependencyModules.SourceGenerator by Ian Johnson ](/docs/DependencyModules.SourceGenerator)|2025-02-16 => 16 February 2025 | [DependencyInjection](/docs/Categories/DependencyInjection) | |184| [MockMe by connorivy ](/docs/MockMe)|2025-02-10 => 10 February 2025 | [Tests](/docs/Categories/Tests) | diff --git a/v2/rscg_examples_site/src/components/HomepageFeatures/index.js b/v2/rscg_examples_site/src/components/HomepageFeatures/index.js index aa7c60932..8052e4ba6 100644 --- a/v2/rscg_examples_site/src/components/HomepageFeatures/index.js +++ b/v2/rscg_examples_site/src/components/HomepageFeatures/index.js @@ -4,7 +4,7 @@ import styles from './styles.module.css'; const FeatureList = [ { -title: '277 Examples (16 from MSFT)', +title: '278 Examples (16 from MSFT)', Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default, description: ( <> diff --git a/v2/rscg_examples_site/static/exports/RSCG.json b/v2/rscg_examples_site/static/exports/RSCG.json index e5eb212ef..fbc42e3d5 100644 --- a/v2/rscg_examples_site/static/exports/RSCG.json +++ b/v2/rscg_examples_site/static/exports/RSCG.json @@ -1495,7 +1495,7 @@ "Link": "https://ignatandrei.github.io/RSCG_Examples/v2/docs/EntityLengths.Generator", "NuGet": "https://www.nuget.org/packages/EntityLengths.Generator/", "Source": "https://github.com/TarasKovalenko/EntityLengths.Generator/", - "Category": "Database", + "Category": "EntityFramework", "AddedOn": "2025-02-19T00:00:00" }, { @@ -2217,6 +2217,14 @@ "Source": "https://github.com/JanusMael/Bennewitz.Ninja.AutoVersioning", "Category": "EnhancementProject", "AddedOn": "2026-07-04T00:00:00" + }, + { + "Name": "Atulin.AutoDbSet", + "Link": "https://ignatandrei.github.io/RSCG_Examples/v2/docs/Atulin.AutoDbSet", + "NuGet": "https://www.nuget.org/packages/Atulin.AutoDbSet/", + "Source": "https://github.com/Atulin/AutoDbSet", + "Category": "EntityFramework", + "AddedOn": "2026-08-18T00:00:00" } ] } \ No newline at end of file diff --git a/v2/rscg_examples_site/static/exports/RSCG.xlsx b/v2/rscg_examples_site/static/exports/RSCG.xlsx index b31bd8353..57bad84aa 100644 Binary files a/v2/rscg_examples_site/static/exports/RSCG.xlsx and b/v2/rscg_examples_site/static/exports/RSCG.xlsx differ diff --git a/v2/rscg_examples_site/static/sources/Atulin.AutoDbSet.zip b/v2/rscg_examples_site/static/sources/Atulin.AutoDbSet.zip new file mode 100644 index 000000000..242111619 Binary files /dev/null and b/v2/rscg_examples_site/static/sources/Atulin.AutoDbSet.zip differ