Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to Starter template to include a database with EF Core and migrations #4206

Open
AndriySvyryd opened this issue May 16, 2024 · 5 comments
Labels
area-templates feature A single user-facing feature. Can be grouped under an epic. help wanted Issue that is a good candidate for community contribution.

Comments

@AndriySvyryd
Copy link
Member

Based on https://github.com/dotnet/aspire-samples/tree/main/samples/DatabaseMigrations/DatabaseMigrations.MigrationService with placeholders for provider-specific code

@davidfowl davidfowl added the feature A single user-facing feature. Can be grouped under an epic. label Sep 15, 2024
@davidfowl
Copy link
Member

I think we should consider another sample template that's crud + EF + postgres, showing how to use migrations etc.

@DamianEdwards
Copy link
Member

Or we could just add it to the existing starter template, potentially as an option.

@DamianEdwards
Copy link
Member

DamianEdwards commented Sep 18, 2024

Strawman with some open questions:

We get a lot of feedback about what patterns work well to configure, initialize, and manage a database using EF Core as part of an Aspire app. We have some samples and documentation on this but we should take this guidance to the next level and include it in our starter template.

Rough idea of what this would include:

  • A new option on the template to include a database that allows selecting between the supported database integrations: PostgreSQL, MS SQL Server, MySQL, MongoDB, or Oracle
    • ❓ Should we limit this to just PostgreSQL and MS SQL Server? Some other combo?
  • A simple page in the Blazor app that uses the database and demonstrates basic CRUD, e.g. a Todo's list
  • A new API in the API project that exposes an HTTP API for the data in the database (this aligns with the webapiaot template so we can lift the relevant implementation from there)
    • ❓ Should this be a new API added in the existing project or should we separate into its own API project?
  • A new worker service project to own and run the migrations based on the existing sample
  • Relevant code in the AppHost project to add the database server and instance resources, the new worker service project, and configure the API & worker service projects to reference the database resource and WaitFor it
  • Update the tests project to add a test that hits the page that depends on the database
@DamianEdwards DamianEdwards changed the title Add a migration service project template Sep 18, 2024
@davidfowl
Copy link
Member

❓ Should we limit this to just PostgreSQL and MS SQL Server? Some other combo?

  1. PostgreSQL, MS SQL Server

A new API in the API project that exposes an HTTP API for the data in the database (this aligns with the webapiaot template so we can lift the relevant implementation from there)

Yes, we should do the DB stuff in existing API not from the front end directly.

@DamianEdwards DamianEdwards added the help wanted Issue that is a good candidate for community contribution. label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-templates feature A single user-facing feature. Can be grouped under an epic. help wanted Issue that is a good candidate for community contribution.
3 participants