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.
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:
IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
1 Points
6 Posts
Visual Studio 2019 - Incorrect Namespace when adding a new page
Dec 29, 2019 02:08 PM|Dads|LINK
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.
Contributor
3370 Points
1409 Posts
Re: Visual Studio 2019 - Incorrect Namespace when adding a new page
Dec 30, 2019 09:44 AM|samwu|LINK
Hi Dads,
You could reset your visual studio settings like below:
Restores Visual Studio default settings
Environment settings for Visual Studio
Best regards,
sam
Contributor
2619 Points
2752 Posts
Re: Visual Studio 2019 - Incorrect Namespace when adding a new page
Dec 31, 2019 02:32 PM|wavemaster|LINK
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
Member
1 Points
6 Posts
Re: Visual Studio 2019 - Incorrect Namespace when adding a new page
Jan 01, 2020 05:12 AM|Dads|LINK
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