Aspnetcore: Rename IdentityModels.cs in Starter Web Template in VS2015

Created on 10 Jul 2015  路  19Comments  路  Source: dotnet/aspnetcore

The Starter Web Template includes a Models folder which contains ViewModels, and a file called IdentityModels.cs. This file is poorly named since it doesn't include multiple identity models, but rather a single model class, ApplicationUser. It also is hiding the ApplicationDbContext class, which is not a model and which many applications will want to use for their data access (not just for Identity purposes).

Split the file into two files to increase discoverability of the classes it currently contains:
ApplicationUser.cs
ApplicationDbContext.cs

All 19 comments

@rustd

I think we did this on purpose to minimize the number of files in general, but also to make it easier to quickly delete areas of functionality that a user didn't want to use. So we ended up grouping related classes into single files for convenience.

I wrote up some more thoughts and recommendations on improvements for the starter web template here: http://blog.falafel.com/asp-net-5-web-application-template-suggestions/

I'm aware of the goal to minimize the number of files. However, I disagree with it and think the goal of keeping the template clean and easy to change can be achieved, better, using folders instead of files.

Personally for it makes perfectly sense to split the files. If you do not want to have those files you would not choose to create an application with "Individual User Accounts". As @ardalis points out in his blog it would make even more sense to have a different ViewModels folder for those classes which are currently stored inside the Models, as they are in fact ViewModels.

+1

I agree with this proposal and the notions in the blog post.

+1 for the blog post. If you want to group things together to make them easier to delete, then use folders, not files. Get people started down the path of best practices from the get-go.

+1 for me as well on the idea. The last project I was on that was using the built in user auth stuff I was frankly more confused with everything being jumbled together.

+1 for me. The identity stuff has always felt messy in the current templates. I was hoping the new templates would change this. Grouping these largely unrelated items together just helps encourage bad practice.

@rustd any thoughts on this? I think the points being made here are quite reasonable.

+1

I agree, get people started down the path of best practices and if they choose not to follow, that is their prerogative. As .net developers, we need to step up our game so we can gain the respect of the open source community.

+1 The default template should in my opinion be of such quality that it would teach people how to structure their application. At the minimum, the template should adhere to .NET coding conventions. At the moment, the first thing I do is restructure the files, which can't be a good sign.

To enable easy deletion, folders are great. A single class per file is also a big improvement, as it makes finding a file a lot easier. Finally, I would really like to have view models have their own directory, just like the blog post suggests.

+1

+1

bump

+1 from me too... this is consistent with how we generate EF models during reverse engineer too (one file per domain class and one for the context).

+1 I like the idea of having it one class per file.

+1 for that. It is always confusing to find models in the IdentityModels.cs, and I usually end up creating new files on my own for each class.

This issue is being closed because it has not been updated in 3 months.

We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.

please reopen this, still valid ...

@davidreher I believe this file is gone from the upcoming set of templates. In fact, I think it was already gone for quite some time. If you believe there is still an issue, can you let me know what version you're running, and exactly where you're seeing a problem? Thanks!

Was this page helpful?
0 / 5 - 0 ratings