In Musical Store,MVC ,I have created tables and created Entity data model.But i got this error.I cant Understand this error.Pls help me to solve this issue.
The type 'MvcApplication1.Models.album' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive, nested
or generic, and does not inherit from EntityObject.
'Unable to retrieve Metadata for mvc2.models.student'.One or more validation errors were detected during model generation. System.Data.Edm.EdmEntitytype:Entity type:'Enrollments' has no key defined.Define the key for this entity type.
System.
Data.Edm.EdmEntitytype:Entityset:enrollment is based on type Enrollments that has no keys defined. I followed the tutorial:http://www.asp.net/entity-framework/tutorials/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application
Pls help me in this issue.I was new to MVC.Thanks on advance
even i done the chage i still get the error,Can u pls tell me the steps to be followed.I do know what is the mistake i done.I will be thankful to u if this issue is solved.
smanjula
Member
205 Points
349 Posts
Musical store MVC Mapping
May 31, 2011 09:23 AM|LINK
Hai,
In Musical Store,MVC ,I have created tables and created Entity data model.But i got this error.I cant Understand this error.Pls help me to solve this issue.
The type 'MvcApplication1.Models.album' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive, nested or generic, and does not inherit from EntityObject.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Musical store MVC Mapping
Jun 02, 2011 02:05 AM|LINK
Hello again:)
How did you do with that?
Please tell us in details step by step of your creating EF models.
with your screen is well welcomed.
Thx
smanjula
Member
205 Points
349 Posts
Re: Musical store MVC Mapping
Jun 02, 2011 04:04 AM|LINK
sample
smanjula
Member
205 Points
349 Posts
Re: Musical store MVC Mapping
Jun 02, 2011 04:43 AM|LINK
Hai,
First I created a database by right clicking on the App_Data Folder.
Next i created 3 tables(enrollment,student,course)
Next i created Model.Edmx by right clicking on the Models Folder.
Then i created school context.cs file.
for class Enrollment.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Musical store MVC Mapping
Jun 02, 2011 05:11 AM|LINK
Hello again:)
1)Please confirm that your "courseid" is really fitting what you've defined in the db, pay attention to spelling worng or case sensitive...
2) If still fails, please——
1. Include the following namespace: using System.ComponentModel.DataAnnotations;
2. Add attribute [key] to define which is your primary key.
Thx again.
smanjula
Member
205 Points
349 Posts
Re: Musical store MVC Mapping
Jun 02, 2011 05:20 AM|LINK
Hai,
In student Table i have the columns,
sid(primary key),Lastname.firstmidname,enrollmentdate
In course table i have the columns,
cid(primary key),title,credits,enrollmentid
In enrollment table i have the columns,
courseid,studentid,grade.
In student.cs file i have,
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Musical store MVC Mapping
Jun 02, 2011 05:28 AM|LINK
smanjula
Member
205 Points
349 Posts
Re: Musical store MVC Mapping
Jun 02, 2011 05:37 AM|LINK
I have changed as u said.Still the error continues.
Can u pls explain the steps to be followed clearly to display datas from database in mvc.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Musical store MVC Mapping
Jun 02, 2011 05:46 AM|LINK
Hello again:)
I'll do a demo and have a try. And I'll tell you later about my result.
Would you mind leaving your mailbox so as to let me send you my codes?
Thx
smanjula
Member
205 Points
349 Posts
Re: Musical store MVC Mapping
Jun 02, 2011 06:36 AM|LINK
hai,
My Mail id is:2010smanjula@gmail.com.