Link to home
Start Free TrialLog in
Avatar of dshi15
dshi15Flag for United States of America

asked on

LINQ The type or namespace "School Model" could not be found

hi Expert,

I have this line in error

public class StudentController : Controller
    {

SchoolModel db = new SchoolModel();

The type or namespace "School Model" could not be found

I have person.edmx under Models, only contains person table in school database

Model NameSpace is "SchoolModel"

Web.config

  <add name="SchoolEntities" connectionString="metadata=res://*/Models.Person.csdl|res://*/Models.Person.ssdl|res://*/Models.Person.msl;provider=System.Data.SqlClient;provider connection string="data source=DSHH;initial catalog=School;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />


Thanks in advance.
Avatar of masterpass
masterpass
Flag of India image

Avatar of Craig Wagner
If your edmx is named "person" then I suspect your ObjectContext is something like personEntities, not SchoolModel. However, without seeing the project I can't tell for sure.

Try this...

Open you EDMX in the designer. On the background of the EDMX (NOT the table definition) right-click and select Properties. In the Properties window look at the value of "Entity Container Name." That's the thing you need to instantiate.
According to your config your entity model is of type SchoolEntities not SchoolModel, so try:
SchoolEntities db = new SchoolEntities()

Open in new window

Avatar of dshi15

ASKER

hi Experts,

I tried SchoolEntities db = new SchoolEntities();

and it still say The type or namespace "SchoolEntities" could not be found.

After word new, I can see
SchoolEntities on the select object list but somehow visual studio couldn't recognized it.

I use 2010 visual studio  and 2012 sql server.

any more suggestion?

Thank you
Did you check the framework your project is on ?
Avatar of dshi15

ASKER

no, how I can check?
Avatar of dshi15

ASKER

I followed online instruction

Go to start ==> Programs ==> Microsoft Visual Studio 2010 ==> Visual Studio Tools ==> Visual Studio 2010 Command Prompt and typed clrver

these are what I got.

v2.0.50727
v4.0.30319
right click on the mvc project and then select properties. you will see target framework there.
Avatar of dshi15

ASKER

>>right click on the mvc project and then select properties. you will see target framework there.


It shows .Net Framework 4.0
alright .. Can you post a screenshot of your SchoolModel  class ?
Avatar of dshi15

ASKER

I attached screen shot and I followed this online tutorial

http://www.asp.net/mvc/tutorials/older-versions/getting-started-with-mvc/getting-started-with-mvc-part1

I couldn't add new Movie table by follow the tutorial

so instead use Movie list and I use person table already in School database.

Thanks,
Doc1.docx
ASKER CERTIFIED SOLUTION
Avatar of masterpass
masterpass
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dshi15

ASKER

Thank you very much, it works. I really appreciate you spend time to help me. (The tutorial didn't mention that).
Avatar of dshi15

ASKER

I've requested that this question be closed as follows:

Accepted answer: 0 points for dshi15's comment #a39878197

for the following reason:

it works.
dshi15 needs to select the best answer and not simply close the question.