Solved

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

Posted on 2014-02-19
16
395 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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 choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

776 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