我的代码中有以下内容:
DbContext = new DataContext();
DbContext.Configuration.AutoDetectChangesEnabled = false;
然后在我的控制器方法中:
// GET /api/Applications
public IEnumerable<Application> Get()
{
return _uow.Applications.GetAll().OrderBy(p => p.Name);
}
但是我仍然收到以下消息:
System.InvalidOperationException was unhandled by user code
HResult=-2146233079
Message=The model backing the 'DataContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
Source=EntityFramework
StackTrace:
有人可以解释为什么会这样。我认为创建上下文后的行会停止此检查。