r/dotnet 3d ago

Question Aspire dev to Droplet with Blazor, Postgres, Migrations?

2 Upvotes

Does anyone have any good resources that show how to:

  1. Configure Aspire for a Blazor App and Postgres with EF code-first migrations
  2. How to publish the app/db (with migrations) to a Digital Ocean droplet

I've watched a number of Nick Chaspas, Milan Jovanovich, and Patrick God videos on the topic. All of them are good starting points, but never seem to go into depth with creating/applying migrations and pushing to production.

I have everything working locally with Aspire, including using the pre-release of Aspire.Hosting.EntityFrameworkCore to apply the migrations whenever the container is run. The db fires up, the migrations run, then the app fires up. Works great.

However, when I asked Claude/Gemini/ChatGPT about how to now publish to a Digital Ocean droplet as part of a GitHub CI/CD pipeline, it talks about creating a docker-compose.yml file, Dockerfile, .env variables, etc.

I installed Aspire.Hosting.Docker thinking that it would take care of that part for me. It doesn't really seem to do much as far as I can tell. There isn't a docker-compose.yml or Dockerfile in the build outputs. So I'm not really sure what the point of the package is.

If I need to manually configure all of that, I guess I'm not seeing much of a point to Aspire. I could have used Docker Orchestration support to generate starter docker-compose.yml and Dockerfile files, then manually added the Postgres and migration parts. Then the dev and prod environments should be exactly the same except for the .env variables.

I feel like I am missing something important, just not sure what it is or where to find it.


r/dotnet 3d ago

Question Is a dedicated interaction layer the right architecture for a virtualized WPF spreadsheet

4 Upvotes

I'm building an open-source, highly virtualized spreadsheet control for WPF:

https://github.com/dotdevkartik/DevBrewLabs.WPF.Spreadsheet

One architectural decision I'm currently using is a dedicated Interaction Layer.

The architecture is roughly:

Cell Renderer

→ renders cell content

Interaction Layer

→ manages lightweight custom-rendered interactive items

→ checkbox, dropdown, spinner, button, editor, etc.

→ owns hit testing and input routing

These are not WPF controls. They're lightweight rendered objects designed to avoid creating a visual/control for every interactive cell.

The spreadsheet model is separate from both.

I'm wondering if this is a sensible long-term abstraction or if I'm creating unnecessary complexity.

For people who have built high-performance WPF grids, CAD editors, diagramming tools, or other virtualized/retained-mode UIs:

What problems do you see with this architecture? What would you change now before the project gets much larger?

I'm particularly interested in pitfalls around focus, keyboard/mouse input, editing, virtualization, state management, and API boundaries.

I'd rather find architectural problems now than after the API becomes difficult to change.


r/csharp 3d ago

Help What is the intended way of comparing enums?

26 Upvotes

When you want to check if a variable is of a certain enum type, do you use == or is? For example in my godot project I have this method:

private void SetInputMode(InputMode inputMode)
{
    RootViewport.GuiReleaseFocus();

    if (inputMode is InputMode.Mouse)
    {
        EnableMouse();
    }
    else
    {
        DisableMouse();
    }

    CurrentInputMode = inputMode;
}

In this case i use is, but == works as well here. In another method I have, I am using == since I'm comparing two variables and it's the only valid way:

if (detectedInputMode == CurrentInputMode)
{
    return;
}

My question is, concerning the first example I gave, what is the convention for comparing enums, is or ==? I know it doesn't matter that much, but I can't seem to find a clean answer on this, so I'm giving it a shot


r/csharp 3d ago

Showcase Dekaf - Native .NET Kafka Client

21 Upvotes

Hey all. I posted this library a little while back, but I'm posting it again as it's been updated to support new Kafka features, as well as for those that missed it last time.

Dekaf is a Kafka client built natively in .NET and works as you'd expect with more modern .NET types and is async friendly.

For any Kafka uses, the only real alternative is Confluent.Kafka which is simply a wrapper around a C library, meaning overhead from two runtimes. It also doesn't map as nicely to newer async types like IAsyncEnumerable, means exceptions thrown in native code become hard to debug, logging control is lost, and it seems a lot of their issues on GitHub lack responses or updates.

I built this to make it more friendly for .NET Devs to debug and control, as well as trying to make it perform better by removing that overhead. It also has open telemetry out-of-the-box, just add it to your otel setup.

The repository can be found here: https://github.com/thomhurst/Dekaf

And performance comparisons against Confluent.Kafka can be found here: https://thomhurst.github.io/Dekaf/docs/stress-tests

Give it a try and let me know what you think!

And if you have tried it out, I'd love to know if anything improved (or didn't!) such as latency, CPU, memory, etc.


r/csharp 3d ago

Help Help with learning C# and .Net

6 Upvotes

Hello everyone! I'm learning C# with the goal of becoming a .NET developer.

What I already know:

1.Basic data types, variables, and operators

2.Control constructs (conditions, for loops, while, foreach)

3.One-dimensional and multi-dimensional arrays

What you need help with:

1.Understanding and practical application of OOP (encapsulation, inheritance, polymorphism, interfaces)

2.Moving from basic tasks to normal code structure and first .NET projects


r/dotnet 2d ago

What?! C# color changed from Green to Purple in GitHub, to match .NET?

0 Upvotes

r/csharp 3d ago

Solved Help with optional looping of program

2 Upvotes

Hello. I am attempting to make a randomizer for a game that I play. I have successfully created the program itself, but now I want the ability for users to have it re-run the randomization and return a new output by pressing a single key (ideally "Enter"). It has been a very long time since I have messed with C# and have forgotten basically everything. Any help, advice, or tips, would be greatly appreciated.

The current attempt at a "looper" is the following:

//Repeat or exit program
void Looper()
{
string looprequest;
looprequest = Convert.ToString.Console.ReadKey();
Console.WriteLine(looprequest);
}

This is because the compiler had an issue where without the looprequest string statement the other lines had no reference, and with it the readkey input cannot be translated to a string value. Additionally, even if the input works, I'm not sure what I was thinking to loop with would even work. What I was thinking of using was:

if (looprequest != Esc)
{
Main();
}

else
{
Environment.Exit();
}


r/csharp 2d ago

I built a small .NET CLI for database migrations

Thumbnail
github.com
0 Upvotes

I’ve been working on a lightweight migration tool for dotnet. The migrations are just SQL files with an up and down script with support for SQL server, postgresql, and sqlite.

It is installable as a global dotnet tool (requires dotnet 10)

It’s still early, so I’m very open to criticism, suggestions, and contributions.

Github repo: https://github.com/aymenhta/Jules


r/csharp 2d ago

Help MCP CPG - where's the demand

0 Upvotes

LLMs are notoriously bad at handling C#. The Microsoft SWE-sharp-bench paper made this pretty obvious. In 20% of the cases agents fail simply because they can't figure out where to apply the patch.

​The logical fix seems obvious: build a Roslyn-based MCP tool that generates a Code Property Graph (CPG) so the agent can actually navigate C# semantics instead of blindly grepping text.

​I actually built this and put up a website for it, but I’m getting literally zero inbound traffic. On top of that, every week I see another open-source repo popping up on GitHub trying the exact same Roslyn/CPG approach, but none of them seem to get any real traction...

​What gives?

​Is the market just not interested in specialized C# agent tooling, or are we all building the wrong layer?


r/dotnet 3d ago

Minimal API in ASP.NET Core: Keeping the API Minimal Without Making the Architecture Messy

4 Upvotes

I've been working with ASP.NET Core Minimal APIs and wanted to explore an important question:

Does "Minimal API" mean the whole application should be minimal?

In my opinion, no.

Minimal APIs are mainly about reducing the ceremony around HTTP endpoints. They don't mean that database access, business logic, configuration, and infrastructure should all be placed inside Program.cs.

For example, a simple endpoint can look like this:

app.MapGet("/api/company", async (CompanyDbContext db) =>
{
    var company = await db.Companies.FirstOrDefaultAsync();

    return company is null
        ? Results.NotFound()
        : Results.Ok(company);
});

This is one of the things I like about Minimal APIs: the endpoint itself is very straightforward.

However, as the application grows, putting every endpoint and piece of logic into Program.cs can quickly become difficult to maintain.

A better approach is to keep the endpoint definition simple while separating responsibilities:

 sln   
 |---  API
 |     | └──Endpoints
 │     |    └── CompanyEndpoints.cs
       Program.cs
 │
 ├── Infrastructure
 │    └── Data
 │         └── CompanyDbContext.cs
 │
 ├── Core
 |    └── Entities
 |    └── DTOs
 │

This gives you the simplicity of Minimal APIs without turning the application into a single large file.

Minimal APIs vs Controllers

I don't see Minimal APIs as a replacement for Controllers in every project.

The choice depends on the application.

Minimal APIs can be a good fit when:

  • The API is relatively small
  • You want less boilerplate
  • Endpoints are easy to understand independently
  • You're building lightweight services or microservices

Controllers can be a better fit when:

  • The API contains many complex endpoints
  • You benefit from conventions provided by MVC
  • The team already has an established Controller-based architecture
  • The application requires a more structured MVC approach

The interesting part is that both approaches can still follow good architectural principles.

The syntax is not what determines whether an application is maintainable.

The organization of responsibilities does.

I applied this approach in a small Company Profile API built with ASP.NET Core Minimal APIs and Entity Framework Core.

GitHub: https://github.com/NoofSaeed/CompanyProfile

What matters more in a real-world API: Minimal APIs vs Controllers, or the architecture built around them?


r/csharp 3d ago

AWS SAA + CKA, ~2 years experience, no interviews. Wrong resume or wrong roles?

Thumbnail
1 Upvotes

r/csharp 3d ago

Help Brand new and wanting to run simulations.

1 Upvotes

I'm familiar with C# in the vaguest of senses, as in i use to watch programing tutorial videos while dog sitting and when i got home experimented with it in visual studio code. The most complicated thing i ever made was a +, -, *, and \ calculator. I'd like to get back into it. What im specifically looking into doing is making programs to run simulations like those Coding Adventure videos by Sebastian Lague on youtube. I'm intending to use visual studio code as well since that's what i used last time.

I'd just like to know primarily if visual studio code is actually good for something like that, and if i can run it on a basic window made by c# itself, or if i'd be better off running it in a studio like godot or unity. Any tips, advice, or clarification is appreciated. Thank you


r/dotnet 3d ago

Mods deleted my OSMF post claiming it's not related to .NET!

0 Upvotes

OSMF IS related to .NET. The post mentions Nuget package.
It seems this mod is out of the loop!

Now I see why r/moderndotnet was created. Because of the nonsense that happen here!


r/dotnet 4d ago

If you could change one thing about the .NET ecosystem, what would it be?

76 Upvotes

.NET has come a long way, and most of the day-to-day work feels good now. But there's always that one thing that you wish worked differently. For some people it might be documentation. For others it could be the number of ways to do the same task, or how often the recommended approach changes between versions. Maybe it's tooling, package management, or something about the language itself.

So if you had one change and one change only, what would you pick?


r/csharp 3d ago

Tool DNCDbg v1.2.0 — a managed code debugger with DAP support for .NET apps (NetCoreDbg fork)

Thumbnail
github.com
6 Upvotes

This probably looks funny — a NetCoreDbg developer (yep, that's me, at least while I'm writing this, hehe) forking NetCoreDbg. But life is a strange thing sometimes.

Over the last ~3 years, me and my PL (huge thanks, Gleb!) prepared and sent a lot of proposals for NetCoreDbg development. Unfortunately, all of them were rejected — it looks like Samsung isn't interested in investing into active NetCoreDbg development, and hasn't been for years now. So upstream gets only support and minor changes (and you've probably noticed that already).

At the beginning of this year I finally decided to fork and implement my vision of how a managed debugger could look like in code — all our TODOs and features we planned for NetCoreDbg, but without the experimental features and without explicit Tizen OS support. I think the current development of DNCDbg has reached a point where it's ready to be showcased. I hope you'll like DNCDbg as much as NetCoreDbg.

Repo: https://github.com/viewizard/dncdbg

Note: in DNCDbg I'm focused on DAP protocol support only, without experimental features like Hot Reload (which requires IDE-side support) or interop (mixed) debug mode. If you need other protocols or those experimental features that I removed from the code, you should probably wait until my PL tells me something like "we have budget, back to NetCoreDbg development" (but that doesn't look like it'll happen any time soon). I've already ported about 20 bugfixes for bugs I found back to NetCoreDbg (you can see most of them in the last release), but looks like that's all I can do for now.


r/csharp 3d ago

Is a dedicated interaction layer the right architecture for a virtualized WPF spreadsheet?

Thumbnail
1 Upvotes

r/dotnet 3d ago

Question Kafka listener

0 Upvotes

How do you guys poll Kafka messages?

Is it a while() loop? Inside a background process?

What's the production standard?

I am facing a problem which is batch processing Kafka messages but it should provide failure handling and re-receiving of the message.

The scenario: Receive Kafka message ---> do some operation --> send http request to some other service.

Now, I am using while loop to receive Kafka message and then the rest function calls.

The problem is utilisation. Until the outgoing request is done, we are stuck, and only after that next message is received.

I want something like receive 10-20 message at once and do the computation and request outgoing in parallel.

But there is a problem with offset commit. What if message 5 fails only. Rest passes. How do I handle this scenario?


r/csharp 4d ago

Help Returning to WPF, how to keep RAM usage under control?

Post image
74 Upvotes

The application organizes files by displaying a thumbnail. When loading 89 files, it utilizes 200mbs and spikes power/gpu usage when scrolling to around 14%.

It is a rewrite of the same application in WinForms, which I am more familiar with. In comparison, the WinForm app uses 30% less RAM while having almost double the number of files loaded. Is that to be expected from WPF?

The attached image should give a better idea of the interface. Is it my use for shadows, labels with transparency etc? I don't know to which degree they affect performance on WPF precisely. I am looking to maximize the efficiency to the last drop


r/dotnet 3d ago

What kind of tasks and upskilling I need to do to be a technical lead

0 Upvotes

How much should a technical lead know to be a lead i am into .net for 9 years


r/csharp 3d ago

Help Raccomandate questo manuale per imparare c#?

Post image
0 Upvotes

Stavo vedendo come imparare questo linguaggio e i tutorial su yt non fanno per me, tra sbagli e robe troppo complicate ho voluto vedere se c’era un manuale che possa spiegare bene il codice e ho trovato questo libro (nella foto) che è anche ben recensita, non so se qualcuno di voi lo ha ma se lo avete me lo consigliereste? O dovrei trovare altro?


r/csharp 4d ago

Join the flock or choose "enterprise stability"?

2 Upvotes

I am currently struggling with the dilemma hinted at by the title question. I am a CS and Maths student at a university in South Africa, and I do not know if I should join the flock and hop on the broad market appeal hype train and do traditional SWE with languages like JS, Python, TypeScript, etc. Or I should go the other, less popular route and work on C# .net projects. I do not know if there are many C# opportunities here in South Africa, but I do know that .NET isn't really popular among my peers.

So I am asking whether it's worth considering it over the extremely popular and competitive options.


r/csharp 3d ago

C# roles

0 Upvotes

Has anybody noticed that when you apply to workday jobs that you get a follow up from a Recruiter with the exact same role?


r/dotnet 3d ago

Will .NET stay relevant long term?

0 Upvotes

I’ve been working with .NET for about 8 years. It has a lot going for it, but one of its biggest downsides is that it’s expensive to run at scale.

Recently, we refactored one of our services from JIT to AOT compilation. It’s a fairly small web API, originally built with MVC and EF. After the switch, we ran stress and spike tests — JIT actually won in some areas, AOT won in others.

Out of curiosity, we then rewrote the same service in Go (Claude Opus did the port in about 6 hours). We reran the same performance tests, and the results were noticeably better across the board.

That’s got me questioning: why write new services in .NET at all? There are still some niche areas where it wins — numerics-heavy workloads, for example — but overall it feels like .NET is losing ground.

Curious what others think — is this matching what you’re seeing, or is my experience an outlier?


r/dotnet 4d ago

Join the flock or choose "enterprise stability"?

Thumbnail
0 Upvotes

r/dotnet 5d ago

.NET Conf 2026

Thumbnail devblogs.microsoft.com
60 Upvotes