Skip to content

Conversation

@lauxjpn
Copy link
Collaborator

@lauxjpn lauxjpn commented Dec 3, 2023

Allows setting a DbDataSource instance either as part of a UseMySql() call or as a service via dependency injection.

Because we cannot alter the connection string of a DbDataSource, it needs to be manually populated with the mandatory options of AllowUserVariables=True;UseAffectedRows=False for Pomelo.

UseMySql()

var dataSource = new MySqlDataSource("Server=MyHost;AllowUserVariables=True;UseAffectedRows=False");

// ...

/* [...] */.UseMySql(
    dataSource, // <-- DbDataSource
    serverVersion,
    options => /* [...] */ )

ServiceCollection

var serviceCollection = new ServiceCollection();
serviceCollection
    .AddMySqlDataSource("Server=MyHost;Allow User Variables=True;Use Affected Rows=False") // <-- DbDataSource
    .AddDbContext<MyDbContext>(o => o.UseMySql(serverVersion));

The AddMySqlDataSource() extension method requires a reference to the MySqlConnector.DependencyInjection package.


Fixes #1817

@lauxjpn lauxjpn force-pushed the feature/dbdatasource branch from 5b060aa to f56c994 Compare December 3, 2023 17:26
@lauxjpn lauxjpn merged commit b2bfea5 into PomeloFoundation:master Dec 4, 2023
@lauxjpn lauxjpn deleted the feature/dbdatasource branch December 4, 2023 16:36
@lauxjpn lauxjpn modified the milestones: 8.0.0-silver.1, 8.0.0 Feb 12, 2024
bgrainger added a commit to mysql-net/aspire that referenced this pull request Mar 8, 2024
bgrainger added a commit to mysql-net/aspire that referenced this pull request Mar 8, 2024
bgrainger added a commit to mysql-net/aspire that referenced this pull request Mar 8, 2024
bgrainger added a commit to mysql-net/aspire that referenced this pull request Mar 9, 2024
This reflects connection string validation changes from PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#1819.

The connection string options required by Pomelo are not set by default for a MySqlDataSource, but are required when using that MySqlDataSource with Pomelo.EntityFrameworkCore.MySql.
RussKie pushed a commit to dotnet/aspire that referenced this pull request Mar 11, 2024
This reflects connection string validation changes from PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#1819.

The connection string options required by Pomelo are not set by default for a MySqlDataSource, but are required when using that MySqlDataSource with Pomelo.EntityFrameworkCore.MySql.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement DbDataSource support

1 participant