Cześć, tworzę właśnie projekt w .NET Core 2.2 i chciałbym połączyć się z bazą MySQL przy pomocy EF Core. Niestety trafiłem na problem i nie mam pewności z czego on wynika.
Poniżej wklejam swój kod:
internal class Program
{
private static void Main(string[] args)
{
using (var context = new Context())
{
context.Database.EnsureCreated();
context.Directories.Add(new Dir() { Name = "nazwa", Path = "sciezka" });
context.SaveChanges();
}
}
}
public class Context : DbContext
{
public DbSet<Dir> Directories { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySql(@"server=server-1;database=db1;user=admin;password=qwerty",
mysqlOptions => { mysqlOptions.ServerVersion(new Version(8, 0, 16), ServerType.MySql); });
}
}
public class Dir
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string Path { get; set; }
}
Błąd, który otrzymuję za każdym razem w gdy próbuję wykonać context.Database.EnsureCreated();:
System.TypeLoadException: 'Method 'PopulateDebugInfo' in type 'Pomelo.EntityFrameworkCore.MySql.Infrastructure.Internal.MySqlOptionsExtension' from assembly 'Pomelo.EntityFrameworkCore.MySql, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.'
Korzystam z pakietów:
Microsoft.EntityFrameworkCore 3.0.0
Pomelo.EntityFrameworkCore.MySql 2.2.0
Będę wdzięczny za wszelkie sugestie i podpowiedzi... :)