dshi15
asked on
LINQ The type or namespace "School Model" could not be found
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://*/M odels.Pers on.csdl|re s://*/Mode ls.Person. ssdl|res:/ /*/Models. Person.msl ;provider= System.Dat a.SqlClien t;provider connection string="data source=DSHH;initial catalog=School;integrated security=True;multipleacti veresultse ts=True;Ap p=EntityFr amework"" providerName="System.Data. EntityClie nt" />
Thanks in advance.
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
Thanks in advance.
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.
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.
According to your config your entity model is of type SchoolEntities not SchoolModel, so try:
SchoolEntities db = new SchoolEntities()
ASKER
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
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
Did you check the framework your project is on ?
ASKER
no, how I can check?
ASKER
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
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
right click on the mvc project and then select properties. you will see target framework there.
instructions here: http://msdn.microsoft.com/en-us/library/bb398202.aspx
ASKER
>>right click on the mvc project and then select properties. you will see target framework there.
It shows .Net Framework 4.0
It shows .Net Framework 4.0
alright .. Can you post a screenshot of your SchoolModel class ?
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much, it works. I really appreciate you spend time to help me. (The tutorial didn't mention that).
ASKER
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.
Accepted answer: 0 points for dshi15's comment #a39878197
for the following reason:
it works.
dshi15 needs to select the best answer and not simply close the question.
ref: http://stackoverflow.com/questions/4764978/the-type-or-namespace-name-could-not-be-found
to change: http://msdn.microsoft.com/en-us/library/bb398202%28v=vs.110%29.aspx