1

I'm new to ASP.Net Identity, and I'm looking for a good tutorial for using Identity in conjunction with other classes in my model.

As an example I have a basic Ratings class that looks like this (from a project not using Identity)

public class Rating
    {
        public int Id { get; set; }
        public Product Product { get; set; }
        public User User { get; set; }
        public int Stars { get; set; }
        public string Comment { get; set; }
        public bool Active { get; set; }

    }

And a User Class that looks a bit like this

public class User
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }
        public ICollection<Rating> Ratings { get; set; }
    }

Looking for a way to achieve the same with Identity. My test project is set up with MVC5, and code first

2
  • Do you use code first? Commented Aug 25, 2014 at 8:41
  • Yes. Most of the tutorials I've found online teaches MVC using code first, so I figured that must be the best practice. Commented Aug 26, 2014 at 5:20

3 Answers 3

3

The recommended solution is to add the properties you need to the ApplicationUser class

You can also use your own "User table", in your case that would be the User class. You'd have to inherit from IdentityUser.

This article has examples of how to do both.

Sign up to request clarification or add additional context in comments.

1 Comment

Clicking on Link ,then you will get Forbidden Message.
1

I agree with Rui.

Here is a site that will teach you How to Extend Identity Accounts and also Implement Based Authentication. When I was starting with Identity, that site taught me a lot.

Comments

0

As a related hint: Watch out when you implement a Unit of Work pattern in your project. ASP.NET identities datacontext needs to be the same as the Uow datacontext, otherwise the whole think will crash.

A good starting point may be this: ASP.NET Identity with Repository and Unit of Work

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.