我有一个使用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");
...
}
框架附带的DbContext
ApplicationUser
如下所示:
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中我使用Collation创建了MyDB“utf8_general_ci”。
但是在数据库迁移时我收到错误:
'Specified key was too long; max key length is 1000 bytes'
我发现使用utf8工作的所有解决方案都不适用于asp.net-core 2.0
asp.net-core 2.0
答案 0 :(得分:0)
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("SET default_storage_engine=INNODB");
}