services.AddDbContextPool<CPSContext>(
options => options.UseMySql(connectionString,
mySqlOptions =>
{
mySqlOptions.ServerVersion(new Version(5, 7, 17), ServerType.MariaDb)
.EnableRetryOnFailure(
maxRetryCount: 10,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null);
}
));
Acoove is my connection string..
I am getting below error

How to add migraton assemmbly to connection i am sin pamlio.ef core
b => b.MigrationsAssembly(typeof(CPSContext).Assembly.FullName))
Initial My confi was
//services.AddDbContext<CPSContext>(options =>
//options.UseMySQL(connectionString, b => b.MigrationsAssembly(typeof(CPSContext).Assembly.FullName)));
Connection string: "CPS": "server=195.22.106.22:3307;database=corepigm_standard;user=corepigm_admin;password=Db@dmin2;"
How to use port number in conncetion string.i a getting below erro

Migrations assembly and similar is set on the options builder argument of the UseMySql call (named mySqlOptions in the code in question) similar to your initial configuration.
However the ServerVersion is not part of the options (hence the compile time error you are getting), but separate parameter of UseMySql between connection string and options builder, as can be seen in the commented code of the screenshot. Also it cannot be created using class constructors, but some static factory methods like AutoDetect, Parse, Create etc.
So the code matching your attempt is something like this
services.AddDbContextPool<CPSContext>(
options => options.UseMySql(connectionString,
ServerVersion.Create(new Version(5, 7, 17), ServerType.MariaDb),
mySqlOptions =>
{
mySqlOptions.EnableRetryOnFailure(
maxRetryCount: 10,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null);
mySqlOptions.MigrationsAssembly(typeof(CPSContext).Assembly.FullName);
}
));
Reference: Configuration Options topic of Pomelo provider.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With