解决了。
在您的迁移文件中,用如下的sql命令替换.Index条目
CreateTable( "dbo.Articles", c => new { articleId = c.Int(nullable: false, identity: true), title = c.String(nullable: false, unipre: false), digest = c.String(unipre: false), content = c.String(nullable: false, unipre: false), imglink = c.String(nullable: false, unipre: false), releaseDate = c.DateTime(precision: 0), userId = c.Int(nullable: false), }) .PrimaryKey(t => t.articleId) .ForeignKey("dbo.Users", t => t.userId, cascadeDelete: true) .Index(t => t.userId); // REMOVE THIS在Up()方法的底部添加相应的SQL命令(对于每个索引)
Sql("CREATE index `IX_userId` on `Articles` (`userId` DESC)");然后我为DataReaders添加的问题与MySQL连接器有关。MySQL连接器不支持多个活动连接。要处理此问题,如果您的控制器中有此命令
public IEnumerable<Article> GetArticles(){ return db.Articles;}现在应该是
public IEnumerable<Article> GetArticles(){ return db.Articles.ToList(); // ToList() will manage the request to work with only ONE data reader, }如果您不知道如何将.Index()转换为SQL命令,只需
update-database -verbose
并且所有的SQL命令将显示



