我一直在项目中使用Entity Framework(5.0)一段时间(VS2012 Express中的ASP.NET MVC).但是,现在,我无法再添加迁移.
PM > Add-Migration -projectName MyProject.DAL TestMigration
Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.
Run Code Online (Sandbox Code Playgroud)
我不知道这是否提供任何线索,但"无法..."文本显示为红色.
我试图启用自动迁移(这是没有意义的,因为我正在尝试将挂起的模型更改写入基于代码的迁移)并导致数据库中所需的迁移.然而,这不是我想要的,因为我在项目中没有迁移.
我试图删除数据库并重新创建数据库.重新创建数据库(直到上一次迁移),但是当我尝试使用Add-Migration时,仍然会出现"无法更新.."错误.
编辑
我尝试了-force参数,但没有区别.
我的配置类的内容(我在上一次迁移后没有改变任何内容):
public Configuration()
{
AutomaticMigrationsEnabled = false;
}
protected override void Seed(Bekosense.DAL.Context.BekosenseContext context)
{
context.Database.ExecuteSqlCommand(Properties.Resources.TriggerAlertMessageDrop);
context.Database.ExecuteSqlCommand(Properties.Resources.TriggerAlertMessageCreate);
context.Database.ExecuteSqlCommand(Properties.Resources.TriggerAlertMessageSentDrop);
context.Database.ExecuteSqlCommand(Properties.Resources.TriggerAlertMessageSentCreate);
context.Database.ExecuteSqlCommand(Properties.Resources.AddDbUsers);
}
Run Code Online (Sandbox Code Playgroud)
编辑2 我发现当我在DbContext中评论以下行时,我能够进行添加迁移:
//Database.SetInitializer(new MigrateDatabaseToLatestVersion<MyContext, …Run Code Online (Sandbox Code Playgroud) 前段时间,我使用Visual Studio(2015)创建了一个WebApp,一个控制台应用程序,并将该控制台应用程序作为OnDemand WebJob链接到WebApp.我将整个发布到Azure和网站,WebJob和Scheduler Job完美地工作.
上周,我注意到WebJob不再运行了.该网站正在不断发展,所以我不确定这是由于我们应用的代码更改还是由于Azure中的某些内容.
无论我尝试什么(包括在webapp上完全删除作业,日程安排和App_Data中的文件夹),当我从VS发布WebApp时,都会重新创建webjob,但调度程序会因以下错误而失败.
Http Action - Response from host 'mysite.scm.azurewebsites.net': 'Unauthorized' Response Headers: Date: Fri, 29 Jan 2016 07:02:01 GMT
Server: Microsoft-IIS/8.0
WWW-Authenticate: Basic realm="site"
Body: 401 - Unauthorized: Access is denied due to invalid credentials. Server Error
Run Code Online (Sandbox Code Playgroud)
有什么可能导致这个问题的线索,或者我可以收集哪些额外信息来追查实际问题?
谢谢,Erik