Base solution for your next web application
Open Closed

v2.1.0 database migration from x.EntityFramework not succeed #1917


User avatar
0
trendline created

When using project.EntityFramework do the database migration, it not succeed. Rum from cmd line, using 'dotnet ef database update', got below message: "Could not find content root folder!"

What happened? No exception was thrown.


13 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    cmd location must be in the root of *.EntityFramework project. Did you tried in that way ? If so, can you send a screenshot of your command line.

    Thanks.

  • User Avatar
    0
    trendline created

    Yes, via "cd" command changed to root direction of the *.EntityFramework,then run "dotnet ef database update", I will share you a screenshot tomorrow

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks, waiting for the screenshot. I couldn't offer you a solution right now.

  • User Avatar
    0
    trendline created

    Error message when running EF cmd to update database [attachment=0:1v8222or]message for ef database update.jpg[/attachment:1v8222or]

  • User Avatar
    0
    aaronwittman created

    This is really funny. I got same error (After change my Solution name)

    Check the logic in <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate-samples/blob/master/SimpleTaskSystem-Core/src/Acme.SimpleTaskApp.Core/Web/WebContentFolderHelper.cs">https://github.com/aspnetboilerplate/as ... rHelper.cs</a>

    Seems like its looking for fixed solution name, and assume it as the Root folder.

    Change it to old Solution name fix this issue.

  • User Avatar
    0
    trendline created

    Yes, just like you said, a strange problem. I changed the name of the solution to the old one, it works fine.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Actually changing solution name after project creatin is not suggested but I understand there might be such a need after some time of development.

    We didn't share our project renaming code because of licensing issues, see <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/issues/200">https://github.com/aspnetzero/aspnet-zero/issues/200</a>.

    In your case I think you need to change project names in WebContentDirectoryFinder.cs. But if you even solve this problem, there might be some other issues.

  • User Avatar
    0
    trendline created

    <cite>ismcagdas: </cite> Hi,

    Actually changing solution name after project creatin is not suggested but I understand there might be such a need after some time of development.

    We didn't share our project renaming code because of licensing issues, see <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/issues/200">https://github.com/aspnetzero/aspnet-zero/issues/200</a>.

    In your case I think you need to change project names in WebContentDirectoryFinder.cs. But if you even solve this problem, there might be some other issues.

    Where I can find WebContentDirectoryFinder.cs file?

  • User Avatar
    0
    hikalkan created
    Support Team

    WebContentDirectoryFinder is located under Web folder of the .Core project. You can search any class in the solution explorer like that:

    [attachment=0:25s9eo45]Clipboard01.jpg[/attachment:25s9eo45]

  • User Avatar
    0
    korp created
    while (!DirectoryContains(directoryInfo.FullName, "MySolution.sln"))
                {
                    if (directoryInfo.Parent == null)
                    {
                        throw new Exception("Could not find content root folder!");
                    }
    
                    directoryInfo = directoryInfo.Parent;
                }
    

    This code should not search for solution name (MySolution.sln) -- this is a auto generated code.

    I have the same issue when deploying to azure (when there is no solution file)

  • User Avatar
    0
    alper created
    Support Team

    it's used only in development environment to work with package manager console window. when you publish it shouldn't be executed

  • User Avatar
    0
    alexanderpilhar created

    I just finished the upgrade from 4.6.1 to 5.0.2 - and encountered the same exception on database-update. Since it was mentioned that this exception occurs because of solution's name (e.g. when it has been renamed) I had a closer look at the solution file. After the upgrade there were two solution files in my project Folder, the old one named Company.ProjectName and the new one named Company.ProjectName.All. So I tried to simply copy the content of the newer solution file into the old solution file, renaming every occurence of Company.ProjectName.All to Company.ProjectName and use this solution file instead of the new one. Still, the exception was thrown. Then I recognized, that WebContentDirectoryFolder.CalculateContentRootFolder() was looking for a solution file named Company.ProjectName.Web.sln - but that didn't exist anywere in my project folder. So I changed that string to look for Company.ProjectName.sln and the exception did not occur anymore. Strangely though, the naked update-project does not have any Problems with Company.ProjectName.Web.sln, only after I merged it with my development-branch the problem occured - so this made me wonder even more. I had a look into the update-project folder and there it was: the Company.ProjectName.Web.sln solution file! I copied the file to my development-branch folder, and nowWebContentDirectoryFolder.CalculateContentRootFolder() can find Company.ProjectName.Web.sln without problems. Long story short: Version Control had no idea of the missing solution file. All's well that ends well.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks @alexanderpilhar :).