Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update database error during Setup-DevEnvironment.ps1 #3865

Closed
zanqi opened this issue May 3, 2017 · 2 comments
Closed

Update database error during Setup-DevEnvironment.ps1 #3865

zanqi opened this issue May 3, 2017 · 2 comments

Comments

@zanqi
Copy link

zanqi commented May 3, 2017

Got the following error when running Setup-DevEnvironment.ps1

ERROR: 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 DbMigrati onsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.

To find out what model is causing this, I went to Visual Studio package manager console, run Add-Migration to see what will be generated:

namespace NuGetGallery.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class WhatIsMissing : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.UserSecurityPolicies",
                c => new
                    {
                        Key = c.Int(nullable: false, identity: true),
                        UserKey = c.Int(nullable: false),
                        Name = c.String(nullable: false),
                        Value = c.String(),
                    })
                .PrimaryKey(t => t.Key)
                .ForeignKey("dbo.Users", t => t.UserKey, cascadeDelete: true)
                .Index(t => t.UserKey);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.UserSecurityPolicies", "UserKey", "dbo.Users");
            DropIndex("dbo.UserSecurityPolicies", new[] { "UserKey" });
            DropTable("dbo.UserSecurityPolicies");
        }
    }
}

Looks like UserSecurityPolicies is not considered migrated to the database. Any idea on why?

@skofman1
Copy link
Contributor

skofman1 commented May 4, 2017

@zanqi , please sync with the latest version and try again. Let us know if it works.

chenriksson added a commit that referenced this issue May 4, 2017
@zanqi
Copy link
Author

zanqi commented May 5, 2017

Tested ok. Thanks.

@zanqi zanqi closed this as completed May 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants