Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# User Authentication with ASP.NET Identity Segmenting and Protecting Data Segmenting Data

is a namespace but is used like a type

I am trying to add User properties to "Entry" but I get this error: " 'User' is a namespace but is used like a type "

   [Required]
    public string UserId { get; set; }

    public User User { get; set; }

UPDATE : I resolved this issue by typing --> public User.User User { get; set; }

1 Answer

Steven Parker
Steven Parker
229,644 Points

The problem is not in this snippet, but somewhere else something is making the compiler think "User" is a namespace instead of a class. I'd look first where the class "User" is defined.

If you need help finding it, you might need to upload the entire project into a repo to allow folks to look it over.

I got this by typing :

     public User.User User { get; set; }
Steven Parker
Steven Parker
229,644 Points

So it was (and still is) a namespace. But it probably isn't intended to be. It should not be necessary to qualify the class name like that. And now I'm certain it's in the module where the class "User" is defined.