Base solution for your next web application
Open Closed

EF Migrations not working in VS2017 #3082


User avatar
0
mikemey01 created

Hi -

I updated version 3.2 to visual studio 2017 since publishing didn't work in vs 2015. With the upgrade, the dotnet ef migrations are broken of course since it no longer has a project.json file.

However EF migrations in the package manager console also are not working, I get the following error: "No DbContext was found in assembly 'ChariotInstruments.PropertyMents.EntityFramework'"

How do I make migrations work again in VS2017? I tried both EntityFramework and EntityFrameworkCore.Tools with no luck.

Thanks.


5 Answer(s)
  • User Avatar
    0
    alirizaadiyahsi created

    Hi,

    Which product (and version) are you using? Latest asp.net zero and aspnet-zero-core working with EF core. First, you should set mvc or host project as start up project, then you should select EF core project (ChariotInstruments.PropertyMents.EntityFrameworkCore) in package manager console.

  • User Avatar
    0
    mikemey01 created

    Hi - I'm using .NET Core/jQuery version 3.2 with .NET 4.6.1 framework.

    Originally the project was using the project.json method in visual studio 2015. Migrations were handled with CLI tool using dotnet ef..

    When I upgraded to visual studio 2017 it convert the project to .csproj files which broke the CLI tooling. However the package manager console does not work either. Note that this version does not use entityframeworkCore, instead it uses EF6 still.

    I'm wondering if it would be best to cut my losses and download version 4.0 of .net zero and copy my code into that project. If that's the best route - is v4.0 a stable version? If I build a lot of code into this version I don't want to have to do this exercise every few months.

    Thanks.

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Migrator.EF6.Tools was not compatible with new csproj project format, but they have released a new version. We had the same problem while upgrading it. You can see the related issue: <a class="postlink" href="https://github.com/mrahhal/Migrator.EF6/issues/36">https://github.com/mrahhal/Migrator.EF6/issues/36</a>

    However, you can also create a new v4.0 project. We believe v4.0 is fairly stable. And more, it's cross platform, can work on .net core.

    BTW, you don't have to upgrade AspNet Zero to latest version every month we release it. Upgradeability is not AspNet Zero's main goal, because it provides full source code and you can freely modify it. You can read my answer about upgradeability: #1073

  • User Avatar
    0
    mikemey01 created

    Makes sense - I'll start again with v4.0 of the .net core/jquery solution and hopefully standardize on that going forward. It seems like v3.2 was caught in a weird in-between area as EFCore wasn't being used and it was relying on project.json project format. It seems like aspnet zero is standardizing on EFCore's ability to use the PM migrations as opposed to CLI migrations seeing that the step-by-step guide was updated to remove the CLI instructions. Hopefully that remains the route for some time to come.

    Is there anyway to version control the guides with the specific releases so they remain available? They're very handy references but difficult to follow as they change with the new version releases.

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Actually we are using version control for documents: <a class="postlink" href="https://github.com/aspnetzero/documents/">https://github.com/aspnetzero/documents/</a> For instance, you can download v3.4 documents from <a class="postlink" href="https://github.com/aspnetzero/documents/archive/v3.4.zip">https://github.com/aspnetzero/documents ... e/v3.4.zip</a>

    Have a nice day.