Base solution for your next web application
Open Closed

Version 3.2 + VS2017 = EF Error #2653


User avatar
0
justinp created
  1. Downloaded v3.2 and opened the API .sln.
  2. Modified the connection string to point to a database (used this same database previously, so it should work).
  3. Went to root directory of entity framework project and ran 'dotnet ef database update.'
  4. Get the following error:
Unhandled Exception: System.IO.FileNotFoundException: Could not find file 'D:\Users\Justin\Downloads\ApolloEHR\aspnet-core\src\ApolloEHR.EntityFramework\project.json'.

10 Answer(s)
  • User Avatar
    0
    trendline created

    Are you using VS2017? If so, please update EF.Migrator.Tool to latest version (1.1.0), the issue already resolved by the author.

  • User Avatar
    0
    justinp created

    Thank you for the reply.

    Yes, I'm switching to VS2017 and aware that some things are different (project.json vs global.json) and working through that. However your suggestion did not resolve the issue.

    The following packages that are prompted to be updated when the solution is opened, which does include the one you mentioned.

    xunit -> v2.2.0 xunit.extensibility.execution -> v2.2.0 xunit.runner.visualstudio -> v2.2.0 Microsoft.NET.Test.Sdk -> v15.0.0 Migrator.EF6.Tools -> v1.1.0

    After upgrading and restoring the packages, I did the following:

    Set Web.Host project as default Built the solution

    You mentioned using the Migrate tool. As I mentioned in this post the documentation referenced is missing: [http://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=5370])

    Running console from inside folder: No executable found matching command "dotnet-ef"

    Running from Package Manager Console: PM> update-database The EntityFramework package is not installed on project 'ApolloEHR.EntityFramework'.

    So I checked, and just like the error says EntityFramework wasn't installed! Installed it, then get the errors about the project.json missing.

    There should be either both clear documentation on the workaround using Migrator, and updated documentation on using EF CLI. There are neither that I can find, but if you can point me to it, I'd be grateful.

  • User Avatar
    0
    justinp created

    Continuing with the attempt to get the Entity Framework working since there isn't any documentation on using the Migrator project...

    I've installed the following packages on the EF project: a. Microsoft.EntityFrameworkCore b. Microsoft.EntityFrameworkCore.Tools

    Now I run:

    PM> update-database Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework\Update-Database' for Entity Framework 6. An error occurred while calling method 'ConfigureServices' on startup class 'Startup'. Consider using IDbContextFactory to override the initialization of the DbContext at design-time. Error: This method could not find a user secret ID because the application's entry assembly is not set. Try using the ".AddUserSecrets(string userSecretsId)" or ".AddUserSecrets<TStartup>()" method instead. No DbContext was found in assembly 'Project.EntityFramework'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.

  • User Avatar
    0
    justinp created

    Some more research led to this post: <a class="postlink" href="http://stackoverflow.com/questions/40858155/ef-core-1-1-to-webapi-core-add-migration-fails/40862092#40862092">http://stackoverflow.com/questions/4085 ... 2#40862092</a>

    The issue is related to the builder.AddUserSecrets() call. To fix perform the following steps:

    • Adding the user secret to the assembly (instead of just project.json) by adding attribute [assembly: UserSecretsId("aspnet-TestApp-ce345b64-19cf-4972-b34f-d16f2e7976ed")] to Startup.cs
    • In Startup.cs replace builder.AddUserSecrets() with builder.AddUserSecrets<Startup>(); Reference: InvalidOperationException: Could not find 'UserSecretsIdAttribute' on assembly

    The difference being that builder.AddUserSecrets() is being called from the static class AppConfigurations from inside the Web.Core project (as opposed to the EF or Web.Host projects). So I'm not sure what to change the builder.AddUserSecrets() to builder.AdduserSecrets<T>().

    I would guess that since it wants an IConfigurationBuilder, that it would be builder.AddUserSecrets<ConfigurationBuilder>(). Ideas?

  • User Avatar
    0
    justinp created

    This post does a decent job of explaining the change: <a class="postlink" href="https://github.com/aspnet/Announcements/issues/209">https://github.com/aspnet/Announcements/issues/209</a>

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @JustinP,

    Thank you for the information but we don't suggest to use VS 2017 with the version v3.2 and below for now. We will release v3.3 probably in the beginning of next week and it will be in the new project format.

    Thanks.

  • User Avatar
    0
    justinp created

    Thank you for answering my question _and_letting me know that the new version is coming soon. I will not work on this and will focus my efforts elsewhere.

    Thank you very much!

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Sorry again for wasting your time, please contact with us via email if new version causes any problems for you and we will try to help as soon as possible.

    Thanks.

  • User Avatar
    0
    exlnt created

    I just upgraded all my ABP packages to version 1.5 is that release 3.3 here :[https://github.com/aspnetzero/aspnet-zero/releases/tag/v3.3.0])

    Also, does this 3.3 release allow me to use VS2017 with my solution now?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @exlnt,

    Yes, in v3.3 we only support Visual Studio 2017 because project format is changed from xproj to csproj.