I'm using C# and have an error:
Argument 2: cannot convert from 'string' to 'Microsoft.EntityFrameworkCore.ServerVersion'
using Microsoft.EntityFrameworkCore;
using System;
namespace Infrastructure
{
public class BotContext : DbContext
{
public DbSet<Server> Servers { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseMySql("server=localhost;user=root;port=3306;Connect Timeout=5;");
public class Server
{
public ulong Id { get; set; }
public string Prefix { get; set; }
}
}
}
public class BotContext : DbContext
{
public DbSet<Server> Servers { get; set; }
public BotContext()
{
Database.EnsureCreated();
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySql(
"server=localhost;user=root;port=3306;Connect Timeout=5;",
new MySqlServerVersion(new Version(8, 0, 11))
);
}
public class Server
{
public ulong Id { get; set; }
public string Prefix { get; set; }
}
}
This should help: https://metanit.com/sharp/entityframeworkcore/7.2.php
Apparently, new version of Pomelo
needs more arguments. A simple solution is to add an empty Version
class like this in startup.cs:
services.AddDbContext<ApplicationDB>(options =>
options.UseMySql(Configuration.GetConnectionString("DefaultConnection"), new MySqlServerVersion(new Version())));
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