?
Solved

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

Posted on 2014-02-19
16
Medium Priority
?
414 Views
Last Modified: 2016-02-10
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.
0
Comment
Question by:dshi15
16 Comments
 
LVL 21

Expert Comment

by:masterpass
ID: 39872859
0
 
LVL 21

Expert Comment

by:Craig Wagner
ID: 39873697
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.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 39876507
According to your config your entity model is of type SchoolEntities not SchoolModel, so try:
SchoolEntities db = new SchoolEntities()

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:dshi15
ID: 39877954
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
0
 
LVL 21

Expert Comment

by:masterpass
ID: 39878004
Did you check the framework your project is on ?
0
 
LVL 1

Author Comment

by:dshi15
ID: 39878019
no, how I can check?
0
 
LVL 1

Author Comment

by:dshi15
ID: 39878041
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
0
 
LVL 21

Expert Comment

by:masterpass
ID: 39878047
right click on the mvc project and then select properties. you will see target framework there.
0
 
LVL 21

Expert Comment

by:masterpass
ID: 39878057
0
 
LVL 1

Author Comment

by:dshi15
ID: 39878094
>>right click on the mvc project and then select properties. you will see target framework there.


It shows .Net Framework 4.0
0
 
LVL 21

Expert Comment

by:masterpass
ID: 39878107
alright .. Can you post a screenshot of your SchoolModel  class ?
0
 
LVL 1

Author Comment

by:dshi15
ID: 39878165
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
0
 
LVL 21

Accepted Solution

by:
masterpass earned 2000 total points
ID: 39878181
kind of a long shot. Try to include

using MvcApplication2.Models;
0
 
LVL 1

Author Comment

by:dshi15
ID: 39878197
Thank you very much, it works. I really appreciate you spend time to help me. (The tutorial didn't mention that).
0
 
LVL 1

Author Comment

by:dshi15
ID: 39878231
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.
0
 
LVL 21

Expert Comment

by:masterpass
ID: 39878214
dshi15 needs to select the best answer and not simply close the question.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question