Adds Aspire Oracle EntityFrameworkCore Database component.#1295
Adds Aspire Oracle EntityFrameworkCore Database component.#1295eerhardt merged 18 commits intomicrosoft:mainfrom
Conversation
|
Thanks for this! Can you please log an issue that represents this work? |
Of course, I created the issue #1307 |
|
Triggered package migration for the Oracle EF NuGet package to unblock the build. |
| @@ -0,0 +1,24 @@ | |||
| <Project Sdk="Microsoft.NET.Sdk"> | |||
There was a problem hiding this comment.
Why the .Database suffix? The NuGet package from Oracle does not have this.
There was a problem hiding this comment.
I tried to follow the existing pattern of other EF components where we have Aspire.X.EntityFrameworkCore.Y where:
X is the company/project
Y is the product
Oracle calls its product Oracle Database, so I followed this pattern to leave it open for other Oracle products that may support EntityFramework.
Aspire.Oracle.EntityFrameworkCore.Database
Aspire.Microsoft.EntityFrameworkCore.Cosmos
Aspire.Microsoft.EntityFrameworkCore.SqlServer
Aspire.Npgsql.EntityFrameworkCore.PostgreSQL
There was a problem hiding this comment.
Fair enough. I'm happy with that as a justification as long as @eerhardt is happy as the czar of Aspire components ;)
There was a problem hiding this comment.
The naming pattern we use is in
This should be called Aspire.Oracle.EntityFrameworkCore.
|
@eerhardt PTAL for the component side of this? |
|
@andrevlins we need APIs for the AppModel side of things are you planning on adding this? There isn't much point having a component API surface without the corresponding AppModel APIs :) Take a look at the following for inspiration: |
Yes I was doing this in another PR #1004 |
| /// </summary> | ||
| /// <param name="name">The name of the resource.</param> | ||
| /// <param name="connectionString">The Oracle Database connection string.</param> | ||
| public class OracleDatabaseConnectionResource(string name, string? connectionString) : Resource(name), IOracleDatabaseResource |
There was a problem hiding this comment.
You can remove this type and its associated extension method. We've opted not to have XYZConnection resource types for now.
Yep, we made some changes to try and clarify a few things. You don't need the Oracle connection type anymore - with have a WithReference(ConnectionString) extension method for that kind of thing. You'll need to add The Apologies for the shifting API underneath you we are still shifting things around a bit. If we can get this change in though, it means that when we do future API changes we have to keep this up to date ;) |
Thank you very much for the explanations, I believe I made all the adaptations mentioned.
No problem! It's been great to follow the evolution of this project. |
...Aspire.Oracle.EntityFrameworkCore.Database/Aspire.Oracle.EntityFrameworkCore.Database.csproj
Outdated
Show resolved
Hide resolved
...Aspire.Oracle.EntityFrameworkCore.Database/Aspire.Oracle.EntityFrameworkCore.Database.csproj
Outdated
Show resolved
Hide resolved
...omponents/Aspire.Oracle.EntityFrameworkCore.Database/AspireOracleEFCoreDatabaseExtensions.cs
Outdated
Show resolved
Hide resolved
tests/testproject/TestProject.IntegrationServiceA/TestProject.IntegrationServiceA.csproj
Outdated
Show resolved
Hide resolved
| public static IResourceBuilder<OracleDatabaseContainerResource> AddOracleDatabaseContainer(this IDistributedApplicationBuilder builder, string name, int? port = null, string? password = null) | ||
| { | ||
| password = password ?? Guid.NewGuid().ToString("N"); | ||
| password = password ?? Guid.NewGuid().ToString("N").Substring(0, 30); |
There was a problem hiding this comment.
We should centralize this generated password logic into PasswordUtils @mitchdenny
There was a problem hiding this comment.
Note that it is different than SqlServer.
and MySql
There was a problem hiding this comment.
We should probably just come up with a decent password generator that we can use. What I did for SQL Server was half baked and really only appropriate for inner loop (which luckily is where it is used). I'd be happy to see this go in without change this password generation logic and instead see an issue created where we properly develop out PasswordUtils than can meet our various use cases (needs to be flexible enough to side step various limitations around what the containerized tool can used, and what we can escape in the connection string.
There was a problem hiding this comment.
I know an issue hasn't been created yet, but I saw this comment and opened a PR that might address it: #1469.
src/Components/Aspire.Oracle.EntityFrameworkCore/ConfigurationSchema.json
Show resolved
Hide resolved
| [Theory] | ||
| [InlineData(true)] | ||
| [InlineData(false)] | ||
| [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "EF1001:Internal EF Core API usage.", Justification = "Required to verify pooling without touching DB")] |
There was a problem hiding this comment.
Can you move this to a #pragma only around the code that needs it?
eerhardt
left a comment
There was a problem hiding this comment.
This is getting pretty close. Thanks for this work @andrevlins.
| - Log categories: | ||
| - "Microsoft.AspNetCore.OutputCaching.StackExchangeRedis" | ||
|
|
||
| Aspire.Oracle.EntityFrameworkCore: |
There was a problem hiding this comment.
(nit) Can you keep these are alphabetically ordered?
There was a problem hiding this comment.
Of course, I didn't understand the ordering, sorry.
| builder.AddOracleDatabaseDbContext<MyDbContext>("orcl", settings => settings.HealthChecks = false); | ||
| ``` | ||
|
|
||
| ## AppHost extensions |
There was a problem hiding this comment.
This should also have a code snippet for the code to call AddOracleDatabaseDbContext in the service project.
| /// <summary> | ||
| /// <para>Gets or sets the maximum number of retry attempts.</para> | ||
| /// <value> | ||
| /// The default is 6. | ||
| /// Set it to 0 to disable the retry mechanism. | ||
| /// </value> | ||
| /// </summary> |
There was a problem hiding this comment.
| /// <summary> | |
| /// <para>Gets or sets the maximum number of retry attempts.</para> | |
| /// <value> | |
| /// The default is 6. | |
| /// Set it to 0 to disable the retry mechanism. | |
| /// </value> | |
| /// </summary> | |
| /// <summary> | |
| /// <para>Gets or sets the maximum number of retry attempts.</para> | |
| /// <para>Default value is 6, set it to 0 to disable the retry mechanism.</para> | |
| /// </summary> |
value isn't a valid element in summary. Repeated elsewhere. See
for the latest format.
| "Aspire": { | ||
| "Oracle": { | ||
| "EntityFrameworkCore": { | ||
| "Database": { |
| builder.AddNpgsqlDataSource("postgresdb"); | ||
| builder.AddRabbitMQ("rabbitmqcontainer"); | ||
| builder.AddMongoDBClient("mymongodb"); | ||
| builder.AddOracleClient("freepdb1"); |
There was a problem hiding this comment.
This test program should be using the Oracle EF Component you are adding, not a workaround method and talking to an OracleConnection directly.
There was a problem hiding this comment.
Done. It makes perfect sense, I got a little lost here. Thank you for the explanation.
| app.MapGet("/oracledatabase/verify", VerifyOracleDatabaseAsync); | ||
| } | ||
|
|
||
| private static async Task<IResult> VerifyOracleDatabaseAsync(OracleConnection connection) |
There was a problem hiding this comment.
This should be
| private static async Task<IResult> VerifyOracleDatabaseAsync(OracleConnection connection) | |
| private static async Task<IResult> VerifyOracleDatabaseAsync(MyDbContext dbContext) |
And then using the EF Component you are adding in this PR.
|
I think we should merge this once preview 2 is out the door. |
eerhardt
left a comment
There was a problem hiding this comment.
Just a few more comments to fix up, and then I think this will be good to merge.
Thanks again for the contribution!
tests/Aspire.Hosting.Tests/Oracle/OracleDatabaseFunctionalTests.cs
Outdated
Show resolved
Hide resolved
|
@eerhardt I will update the pr with the new updates to solve the build problems |
Ready |
eerhardt
left a comment
There was a problem hiding this comment.
This looks great. Thanks @andrevlins for the contribution!
No description provided.