locked
Visual Studio 2019 - Incorrect Namespace when adding a new page RRS feed

  • Question

  • User1545552040 posted

    Hi everyone

    In visual studio 2019, when I try to add a new razor page (new scaffolded item) after creating a model, the namespace is not right as I want. the namespace does not contain the folders name between the project name and the individual files. the expected namespace should be "RDAccounting.Pages.Products", but the automatically generated namespace is just "RDAccounting".  Its not including the folder(s)

    The file structure generated automatically as follows.

    RDAccounting(the solution name)

         -Pages

                -Products

                        -Create.cshtml

                        -Delete.cshtml

                        -Details.cshtml

                        -Edit.cshtml

                        -Index.cshtml

    I have to manually correct the namespace of the page everytime i add a new page to include the folder structure or else the namespace would clash.

    Im using Visual studio 2019(latest update) and .net core 2.2.  I'm not having this kind of error before but 2 days ago, i reformatted my machine and reinstalled VS2019... and now the issue is happening. 

    Does anyone have a solution on this? 

    Many thanks.

    Sunday, December 29, 2019 2:08 PM

All replies

  • User288213138 posted

    Hi Dads,

    Dads

    In visual studio 2019, when I try to add a new razor page (new scaffolded item) after creating a model, the namespace is not right as I want. the namespace does not contain the folders name between the project name and the individual files. the expected namespace should be "RDAccounting.Pages.Products", but the automatically generated namespace is just "RDAccounting".  Its not including the folder(s)

    You could reset your visual studio settings like below:

    Restores Visual Studio default settings

    Environment settings for Visual Studio

    Best regards,

    sam

    Monday, December 30, 2019 9:44 AM
  • User379720387 posted

    This may not be relevant to your problem but there is an issue with EF on VS2019.

    Someone at Microsoft suggested I use the preview versions.

    https://developercommunity.visualstudio.com/content/problem/806218/update-model-from-database-fails-in-vs2019-not-in.html?childToView=809981#comment-809981

    Tuesday, December 31, 2019 2:32 PM
  • User1545552040 posted

    Hi Sam,

    I already tried resetting the settings but the issue still persist. Thanks for your response.

    It seems, the Visual studio team acknowledged the issue and have a fix on it already but not yet release to the public.  

    https://developercommunity.visualstudio.com/content/problem/822390/scaffolding-incorrect-namespace.html?inRegister=true

    Regards,

    Ryan

    Wednesday, January 1, 2020 5:12 AM