onTheInternet
onTheInternet

Reputation: 7253

Visual Studio not recognizing namespace in project

I am following a training course on Pluralsight to learn .Net core. I have a folder called 'Data' which contains another folder called 'Entities' that I want to import into my views.

Structure

I want to import those classes so that I can have intellisense when editing my views.

I have a _ViewImports.cshtml file that I've been using to do this. It looks like this.

@using PluralsightTraining.Controllers
@using PluralsightTraining.ViewModels
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"

And these namespace imports work just fine. But when trying to add

@using PluralsightTraining.Data.Entities

I get an error that says "The type or namespace 'entities' does not exist in the namespace 'PluralsightTraining.Data'.

I noticed that when I hit period after PluralsightTraining I get autocomplete to recognize the Data directory but that doesn't happen after I put a period after Data.

AutoComplete

I'm not really sure what I'm doing wrong.

Upvotes: 0

Views: 893

Answers (1)

Sorena Gh
Sorena Gh

Reputation: 32

check files in Data/Entities folder,do the have their namespaces written like this?

 namespace PluralsightTraining.Data.Entities
{
   //Your class here
}

Upvotes: 2

Related Questions