0
votes

I'm having a problem running migrations on my current project.

It all started when I tried to add a migration using Package Manager Console on Visual Studio 2015. The changes made to the Models wouldn't be applied and the migration Up/Down methods were empty.

I tried removing migrations, creating new ones, deleting the database and starting from scratch. Nothing worked.

After all I run a complete Clean in the project using

Main Menu > Build > Batch Build > Clean

After this every time I try to run an EF command on Package Manage Console like:

PM> Update-Database

I get this error:

Could not find assembly 'D:\Repo\Tapr\src\Tapr.Api.\bin\Debug\net461\win7-x64\Tapr.Api.exe'.

I didn't use to target the win7-64 runtime on my project.json now.
I tried doing that and the folder \bin\Debug\net461\win7-x64 doesn't get created.

Any ideas on how to make EF search for the project in the right win10-x64 folder?

Thanks a lot!


Update:

global.json

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-preview2-003156"
  }
}

project.json

{
  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "compile": {
    }
  },
  "dependencies": {
    "IdentityServer4": "1.0.0",
    "IdentityServer4.AspNetIdentity": "1.0.0",
    "IdentityServer4.EntityFramework": "1.0.0",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
    "Microsoft.AspNetCore.Authentication.Facebook": "1.1.*",
    "Microsoft.AspNetCore.Authentication.Google": "1.1.*",
    "Microsoft.AspNetCore.Authentication.LinkedIn": "1.0.1",
    "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.1.0",
    "Microsoft.AspNetCore.Authentication.Twitter": "1.1.*",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.*",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.*",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.*",
    "Microsoft.AspNetCore.StaticFiles": "1.1.*",
    "Microsoft.EntityFrameworkCore": "1.1.0",
    "Microsoft.EntityFrameworkCore.Design": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.*",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.*",
    "Microsoft.Extensions.Logging.Debug": "1.1.*",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
    "System.Linq": "4.0.0",
    "System.Reflection.TypeExtensions": "4.3.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.2.0-preview1-23339",
    "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.2.0-preview1-23339"
  },

  "frameworks": {
    "net461": {
      "dependencies": {
        "Tapr.Utils.Messenger.Email": "1.0.0-*",
        "Tapr.Utils.Messenger.Sms": "1.0.0-*"
      }
    }
  },

  "runtimeOptions": {
    "gcServer": true
  },

  "runtimes": {
    "win10-x64": {}
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config",
      "idsrv3test.pfx"
    ]
  },

  "scripts": {
    "postpublish": [
      "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
    ]
  },

  "configurations": {
    "Debug": {
      "buildOptions": {
        "define": [ "DEBUG", "TRACE" ],
        "emitEntryPoint": true,
        "preserveCompilationContext": true
      }
    },
    "Staging": {
      "buildOptions": {
        "define": [ "STAGING", "TRACE" ],
        "emitEntryPoint": true,
        "preserveCompilationContext": true
      }
    },
    "Release": {
      "buildOptions": {
        "define": [ "RELEASE", "TRACE" ],
        "emitEntryPoint": true,
        "preserveCompilationContext": true,
        "optimize": true,
        "platform": "x64"
      }
    }
  }

}

PM> dotnet --version results in:

1.0.0-preview2-003156

1
Please show your global.json and project.json files, output of dotnet --version (run in console). - Dmitry
Hi Dmitry, thanks for answering. - TaprDeveloper
I updated the question with the information you asked. Thanks. - TaprDeveloper
Did you tried to completely remove runtimes from project.json? Tooling is still a preview, bugs or "uncomplete" features are possible. You may return it back after creating migration if really required. - Dmitry
You solved the issue my friend. Thanks a lot. Would you like to post it as an answer so I can mark it as accepted? - TaprDeveloper

1 Answers

0
votes

Remove runtimes section from project.json completely. You use preview version of tooling - bugs or "uncomplete" features are possible.

You may return runtimes back after creating migration if really required. But re-evaluate, do you really need it? Having runtimes creates Self-contained deployment (more info) where you do not need .NET Core installed on production server, but instead you must have exact runtime on your dev/build machine to put all required files into you distrib/publish folder.