Solved

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

Posted on 2014-02-19
16
392 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
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.
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.
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…

920 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

13 Experts available now in Live!

Get 1:1 Help Now