Skip to content
This repository has been archived by the owner on Dec 20, 2018. It is now read-only.

IdentityDBContext confusion - need more samples and explanation please #767

Closed
CJHarmath opened this issue Mar 9, 2016 · 10 comments
Closed

Comments

@CJHarmath
Copy link

Just started looking at ASP.NET Identity recently and I got stuck with something.
There are way too many confusing stackoverflow questions about how to plug the identity user to custom entity relations.
Also identitydb context by itself is also confusing. Small things like the guid as id etc etc.

Few examples of questions worth reviewing
http://stackoverflow.com/questions/19902756/asp-net-identity-dbcontext-confusion
http://stackoverflow.com/questions/28531201/entitytype-identityuserlogin-has-no-key-defined-define-the-key-for-this-entit
http://stackoverflow.com/questions/9954997/the-member-with-identity-does-not-exist-in-the-metadata-collection-parameter-na

Most of the samples and docs are way too simple, just adding properties to the user but no relations which would be more helpful.
http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

Can you please just do a very simple sample / update the doc to represent how to add let's say a todo list for a logged in user ? And also explain the various pros and cons flying around if one should extend IdentityDbContext and "pollute" the model project with EF dependencies etc.

It might be just me, but I was reading about this in the past few hours and it's still confusing and there seems to be no good story about this.

Disclaimer: I have not spend too much time yet with Identity, so looking at the newbie angle which is I think a very important factor.

Hopefully someone will read it and consider reviewing the docs / samples as for first timers with identity it can really be confusing. New starters should not spend hours with this and going through that many so questions...

Thanks

@CJHarmath
Copy link
Author

Hah, of course I found what I was looking for just after opening this issue
https://github.com/rustd/AspnetIdentitySample

From here
https://blogs.msdn.microsoft.com/webdev/2013/10/20/building-a-simple-todo-application-with-asp-net-identity-and-associating-users-with-todoes/

BTW, I realize it's a 2 years old blog entry, but still the style is terrible to read.

Would be nice if this topic is demonstrated more generally based on those confused stack overflow questions.
I am still not sure why didn't it work for me when I first tried, but this is a nice simple sample which is cool.

@CJHarmath
Copy link
Author

After updating to the latest nuget packages, that sample no longer works, so I wonder if you have an up-to-date version for this ? Thanks

@torrentx
Copy link

torrentx commented Mar 9, 2016

Pretty much can't be done in this version. You'll need to use Identity 2.0 instead. There's a thread here: #585

@blowdart
Copy link
Member

blowdart commented Mar 9, 2016

@Rick-Anderson One for you?

@Rick-Anderson
Copy link
Contributor

Can you please just do a very simple sample / update the doc to represent how to add let's say a todo list for a logged in user ? And also explain the various pros and cons flying around if one should extend IdentityDbContext and "pollute" the model project with EF dependencies etc.

@csharmath Yes this is planned. See dotnet/AspNetCore.Docs#977
I have a MVC5 version of this listed in the issue but it hasn't had a security audit so is not blessed my MSFT. I did it one afternoon.

@CJHarmath
Copy link
Author

Thanks @Rick-Anderson for looking into this!
Looking at your repo, I don't see relationship defined between the ApplicationUser and the Contact and hence the controller is not filtering either based on the logged in user.
That would be useful to have as a reference and its a more realistic sample.

Thanks again

@Rick-Anderson
Copy link
Contributor

@csharmath did you look at the right repo? https://github.com/Rick-Anderson/secureMvc only allows the logged in user to edit their records.

@Rick-Anderson
Copy link
Contributor

@csharmath oops - wrong repo, let me find the right one.

@Rick-Anderson
Copy link
Contributor

@csharmath it's the PR that hasn't been approved. https://github.com/Rick-Anderson/secureMvc/pull/2

@CJHarmath
Copy link
Author

great, thanks for that! I will check later.

@HaoK HaoK closed this as completed Jul 1, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants