【发布时间】:2018-02-01 00:17:16
【问题描述】:
我有一个使用asp.net-core 2.0 构建的应用程序。
我使用Pomelo.EntityFrameworkCore.MySql来集成MySql。
我在 Startup.cs 中使用的配置是:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options => options.UseMySql("Server=localhost;port=3306;database=MyDB;user=MyDb_user;password=test123");
...
}
框架自带的ApplicationUser的DbContext如下:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Customize the ASP.NET Identity model and override the defaults if needed.
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
}
}
现在在 MySql 中,我使用排序规则“utf8_general_ci”创建了 MyDB。
但在 DB 迁移时我收到错误:
'Specified key was too long; max key length is 1000 bytes'
我发现使用 utf8 的所有解决方案都不适用于 asp.net-core 2.0
asp.net-core 2.0 有什么解决方案
【问题讨论】:
-
为电子邮件和用户名关闭 unicode
标签: c# mysql entity-framework asp.net-core asp.net-core-2.0