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

MariaDb ConfigureServices.AddDbContext() broken in alpha-2 #1240

Closed
seagull22 opened this issue Nov 13, 2020 · 3 comments
Closed

MariaDb ConfigureServices.AddDbContext() broken in alpha-2 #1240

seagull22 opened this issue Nov 13, 2020 · 3 comments

Comments

@seagull22
Copy link

Steps to reproduce

Add this statement to your ConfigureServices() method in Startup.cs:

services.AddDbContext<myDbContext>(opts => 
{
    var connStr = "your-value-here";
    var version = new ServerVersion(new Version(10, 5, 5), ServerType.MariaDb);
    opts.UseMySql(connStr, mySqlOptions => mySqlOptions.ServerVersion(version));
});

The issue

The above code compiles and runs well in alpha-1, but in apha-2 it won't compile.

compiler error message:
Startup.cs(49,31): error CS0144: Cannot create an instance of the abstract type or interface 'ServerVersion' 
[Server.csproj]
Startup.cs(50,69): error CS1061: 'MySqlDbContextOptionsBuilder' does not contain a definition for 'ServerVersion' and no accessible extension method 'ServerVersion' accepting a first argument of type 'MySqlDbContextOptionsBuilder' could be found (are you missing a using directive or an assembly reference?) [Server.csproj]

Further technical details

MySQL version: 10.5.5-MariaDB-1:10.5.5+maria~bionic mariadb.org binary distribution
Operating system: Ubuntu 20.04.1 LTS
Pomelo.EntityFrameworkCore.MySql version: 5.0.0-alpha.2
Microsoft.AspNetCore.App version: 5.0.100

Other details about my project setup:

@lauxjpn lauxjpn self-assigned this Nov 13, 2020
@lauxjpn
Copy link
Collaborator

lauxjpn commented Nov 13, 2020

See this breaking change: #1233
Further discussion can also be found at #1088 (comment) and the following posts.

Both references contain all the common ways to set the new mandatory serverVersion parameter.

In short, for your specific case, using MariaDbServerVersion instead of ServerVersion would be a viable option.

@lauxjpn lauxjpn closed this as completed Nov 13, 2020
@seagull22
Copy link
Author

Thanks, I got it working. I didn't see the breaking changes earlier, or I would not have troubled you.

@lauxjpn
Copy link
Collaborator

lauxjpn commented Nov 13, 2020

@seagull22 No worries. We are thinking about making the options to choose from easier discoverable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants