-
Notifications
You must be signed in to change notification settings - Fork 214
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 sample showing how to use the support in Aspire.Hosting for database containers #61
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DamianEdwards
requested review from
davidfowl,
sebastienros,
roji and
eerhardt
December 8, 2023 01:18
DamianEdwards
commented
Dec 8, 2023
DamianEdwards
commented
Dec 8, 2023
DamianEdwards
commented
Dec 8, 2023
eerhardt
approved these changes
Dec 8, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Thanks for writing up this sample.
samples/DatabaseContainers/DatabaseContainers.ServiceDefaults/Extensions.cs
Show resolved
Hide resolved
samples/DatabaseContainers/DatabaseContainers.ApiService/data/mysql/init.sql
Show resolved
Hide resolved
@bgrainger would love your thoughts on this too, esp. the MySql init script as I've never used MySql before and relied on CoPilot and StackOverflow to build 😄 |
DamianEdwards
force-pushed
the
damianedwards/db-containers
branch
from
December 8, 2023 23:00
b9d5573
to
b1f9204
Compare
bgrainger
reviewed
Dec 9, 2023
samples/DatabaseContainers/DatabaseContainers.ApiService/ApiEndpoints.cs
Outdated
Show resolved
Hide resolved
bgrainger
reviewed
Dec 9, 2023
samples/DatabaseContainers/DatabaseContainers.ApiService/ApiEndpoints.cs
Outdated
Show resolved
Hide resolved
bgrainger
reviewed
Dec 9, 2023
samples/DatabaseContainers/DatabaseContainers.ApiService/ApiEndpoints.cs
Outdated
Show resolved
Hide resolved
bgrainger
reviewed
Dec 9, 2023
samples/DatabaseContainers/DatabaseContainers.ApiService/ApiEndpoints.cs
Outdated
Show resolved
Hide resolved
bgrainger
reviewed
Dec 9, 2023
samples/DatabaseContainers/DatabaseContainers.ApiService/ApiEndpoints.cs
Outdated
Show resolved
Hide resolved
DamianEdwards
force-pushed
the
damianedwards/db-containers
branch
from
December 11, 2023 17:45
b1f9204
to
4fd5a9d
Compare
bgrainger
reviewed
Dec 13, 2023
bgrainger
approved these changes
Dec 13, 2023
DamianEdwards
force-pushed
the
damianedwards/db-containers
branch
from
December 13, 2023 18:36
b79e447
to
d82f21d
Compare
Co-authored-by: Bradley Grainger <[email protected]>
DamianEdwards
force-pushed
the
damianedwards/db-containers
branch
from
December 15, 2023 17:45
6852100
to
3665120
Compare
meneasysoft
pushed a commit
to meneasysoft/aspire-samples
that referenced
this pull request
Jul 25, 2024
…ase containers (dotnet#61) * Updating samples for preview.2 * Skip sign check on workload install for now * Update NuGet.config * Update to latest preview.2 build * Update to latest preview.2 build * Fix node sample * Update the version of preview2 to the latest * Updated the dapr sample and instructions * Update Dapr README to call out dapr init (dotnet#66) * Update to latest package versions * WIP * Added DatabaseContainers sample Fixes dotnet#60 * Tweaks * Inject connection from DI instead of DataSource * Update samples/DatabaseContainers/README.md Co-authored-by: Bradley Grainger <[email protected]> * Prepare for release --------- Co-authored-by: David Fowler <[email protected]> Co-authored-by: Balamurugan Chirtsabesan <[email protected]> Co-authored-by: Bradley Grainger <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: Builds on #55
This sample demonstrates how to use the built-in support for database containers in .NET Aspire when not using an ORM like Entity Framework Core, that can handle complicated database initialization logic for you. In this sample, the underlying features of the database container images are utilized to modify the database upon container start, e.g. changing the name of the default database, creating tables and inserting seed data via a .sql script, etc. The API app that depends on the database uses Dapper to make its queries.
The PostgreSQL and MySql containers both support modifying the database name via an environment variable and initializing the database via *.sql scripts in a bound directory. The MS SQL Server container does not support this so instead I adapted their example for customizing the database via a custom container entry point.
Fixes #60