عنوان:

‫کدام پروایدر MySQL با EF Core 3x سازگار است؟


نویسنده: وحید نصیری
تاریخ: ۱۳۹۹/۰۱/۱۱ ۱۰:۵۱
آدرس: www.dntips.ir

There are two MySQL providers for Entity Framework Core:
- The official one from MySQL: MySql.Data.EntityFrameworkCore. As of now, the latest version is 8.0.19, and works with Entity Framework Core 2.1 (and probably also 2.2). Since EF Core 3.0 is a major version with breaking changes, you cannot use it with this provider.
- The Pomelo provider: Pomelo.EntityFrameworkCore.MySql. There is a 3.1 version of this provider.
In other words, if you want to use EF Core 3.0/3.1 with MySQL, at this point you need to use the Pomelo provider (or wait for the official MySQL one to get released).



مشاهده مطلب اصلی

نظرات

  • محسن نجف زاده در ۱۳۹۹/۰۱/۱۲ ۱۳:۳۵
    یک تجربه:
    با توجه به محدودیتی که در موتور انجین InnoDB در MySQL وجود دارد  چنانچه از IdentityDbContext  استفاده می‌کنید، درصورت بکارگیری پروایدر MySQL  چنانچه زمان migration پروژه با مشکلی زیر مواجه شدید
    Specified key was too long; max key length is 767 bytes Mysql error
    می‌توانیم با توجه به اینکه در Utf8 هر کاراکتر چهار بایت فضا اشغال می‌کند، در تابع OnModelCreating طول ویژگی‌های مرتبط رو به صورت دستی به 191 تغییر دهیم (191*4 = 764)
    modelBuilder.Entity<User>().Property(p => p.NormalizedUserName).HasMaxLength(191);
    modelBuilder.Entity<User>().Property(p => p.Email).HasMaxLength(191);
    modelBuilder.Entity<User>().Property(p => p.NormalizedEmail).HasMaxLength(191);
    
    modelBuilder.Entity<UserLogin>().Property(p => p.LoginProvider).HasMaxLength(191);
    modelBuilder.Entity<UserLogin>().Property(p => p.ProviderKey).HasMaxLength(191);
    
    modelBuilder.Entity<UserToken>().Property(p => p.LoginProvider).HasMaxLength(191);
    modelBuilder.Entity<UserToken>().Property(p => p.Name).HasMaxLength(191);