Solved

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

Posted on 2014-02-19
16
390 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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.
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.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now