Solved

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

Posted on 2014-02-19
16
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
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!

 
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 500 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

707 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