aspnetcore
aspnetcore copied to clipboard
Data and Models folders are no longer created for new ASP.NET Core applications
This issue has been moved from a ticket on Developer Community.
[severity:Other]
I’ve just created a new ASP.NET Core web application with the latest version of Visual Studio (16.7.2).
However, Visual Studio no longer creates the Data and Models folders like it did the last time I created a web application.
I know I can create a folder easy enough. But I’m trying to find out why it didn’t set up this structure for me. Has something changed? Is adding the folders enough to support code first? Where do I get templates for the context classes?
Last time this worked for me was months ago. I do not recall the version I was using at the time.
Original Comments
Jonathan Wood on 9/1/2020, 09:50 AM:
I don't know why this changed. But looking at the documentation at https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/model?view=aspnetcore-3.1&tabs=visual-studio, it says to manually create the Models folder.
However, it then says to go ahead and use the `Add-Migration InitialCreate` command, which isn't available in my new project.
Feedback Bot on 9/1/2020, 07:46 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Feedback Bot on 9/1/2020, 08:11 PM:
Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2019#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.
Original Solutions
Ajay Bhargav Baaskaran [MSFT] solved on 9/4/2020, 04:01 PM, 0 votes:
Thanks for contacting us. We have changed our default template to not include identity. You will need to select the required auth option when creating a new project.
Jonathan Wood on 9/4/2020, 05:00 PM:
Whoever wrote this did not read my post.
My issue was not that Identity is not included by default. My issue is that when I don't select the Identity option, I don't get other data scaffolding.
Someone who doesn't need identity might still want a *Data* folder and an `ApplicationDbContext` class, along with installing the components needed for the `Add-Migrations` and `Update-Database` commands.
Leaving identity unselected should not change whether or not data scaffolding is added.
Jonathan Wood solved on 9/1/2020, 09:05 AM, 0 votes:
-----[DELETE]-----
Thanks for contacting us.
If I understand the ask correctly, you would like to have the Data and Models folders being part of the default project template. Can you please confirm this? If not, please be more specific about the ask.
@mkArtakMSFT I would like the same scaffolding added that gets added when I check the option to implement identity for individual accounts (except for identity itself). Even if I don't need user accounts, I may still want a database.
This scaffolding includes:
- Create the Data folder.
- Create the Models folder (less important).
- Create the ApplicationDbContext class.
- Install components so that the Add-Migration and Update-Database commands are available.
- Any other scaffolding added when I select the identity option (with the exception of identity code).
Thanks.
Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
@SoftCircuits thanks for the additional details.
From what we understand, you want a template that contains the setup code for a database that is not tied to identity?
@javiercn Correct. Not wanting identity does not necessarily mean I don't want a database.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
This is still an issue.
This issue can be resolved by selecting authentication type as Individual Account which will add data folder as before. Please refer to below screenshot 
This issue can be resolved by selecting authentication type as
Individual Accountwhich will add data folder as before. Please refer to below screenshot
This worked for me as long as I selected .NET 6.0 instead of 7.0.
I'm not sure if this is actionable at this point. We don't want to assume that if someone is building a Razor Pages and/or MVC application that they will want to be using Entity Framework - plenty of apps don't directly access databases - so we shouldn't opt folks into a dependency that isn't strictly requried for the code in the template to work (note this is not true when you use Invidual Accounts because we do need EF in that case).
I'm going to mark this as by design since the OP doesn't seem to have followed this issue over from vsfeedback anyway.
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.
See our Issue Management Policies for more information.
This is about the ability to choose between code first vs database first. The option should not be taken away let the programmer decide on what approach they want instead of forcing them down a path they would rather not go.