Linux üzerinde dotnet core ile oynamaktayım ve DbContext'i bir mysql Server'a bir bağlantı dizesi ile yapılandırmaya çalışıyorum.DbContextOptions üzerinde UseMysql yöntemi bulunamıyor
benim DBContext şöyle görünür:
using Microsoft.EntityFrameworkCore;
using Models.Entities;
namespace Models {
public class SomeContext : DbContext
{
//alot of dbSets...
public DbSet<SomeEntity> SomeDbSet { get; set; }
public EsportshubContext(DbContextOptions<SomeContext> options) : base(options) {
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMysql //Cannot find this method
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
//using modelBuilder to map some relationships
}
}
}
Benim bağımlılıkları şöyle görünür:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
"Microsoft.AspNetCore.Mvc":"1.0.0",
"Microsoft.EntityFrameworkCore": "1.0.1",
"MySql.Data.Core": "7.0.4-ir-191",
"MySql.Data.EntityFrameworkCore": "7.0.4-ir-191"
},
şunlarla kodda benim Startup.cs mysql sunucusunu kullanmaya çalıştı
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
var connection = @"Server=(localdb)\mssqllocaldb;Database=EFGetStarted.AspNetCore.NewDb;Trusted_Connection=True;";
services.AddDbContext<EsportshubContext>(options => options.UseMysql); //Cannot find UseMysql*
}
Yönergemeyi
değiştirmeye çalıştım mantıklıusing MySQL.Data.EntityFrameworkCore;
-e doğru 210
using Microsoft.EntityFrameworkCore;
? olabilir? ama sonra DbContext ve DbSet'e yapılan tüm referanslar gitti, bu yüzden çözümün bir çeşit karışımı olduğunu düşünüyorum.
MySQL.Data.EntityFrameworkCore.Extensions kullandığınız tam "using deyimi" olduğunu nasıl anladın? – DenLilleMand
Hey, Oracle'ın kodlarını Microsoft'un altına koymanın bir yolu yoktur. * 'Namespace :) –
@IvanStoev: Mysql sağlayıcısını enjekte etmek/kaydetmek için kullanılan uzantı yöntemleri, yani Microsoft'a özgü herhangi bir çerçeveye özgü kod değil. Extension.DependencyInjection', bunun için çok uygundur, çünkü kod, (ASP) .NET Core – Tseng