unable to retrieve metadata for mvc entity data model could not find clr type of tblEmp Entity

Posted by Justkishor under ASP.NET MVC on 2/1/2015 | Points: 10 | Views : 5393 | Status : [Member] | Replies : 2
Step 1: Create a new asp.net mvc 4 web application.

Step 2: Right click on the "Models" folder and add "ADO.NET Entity Data Model". Set Name = EmployeeDataModel.edmx.
On the subsequent screen, select "Generate from database" option and click "Next".

On "Choose your data connection screen", click on "New Connection" button.

Specify the sql server name. In my case, I have sql server installed on my local machine. So I have set "Server Name=(local)". From "Select or enter a database name" dropdownlist, select the Database name and click "OK".

Click "Next".

On "Choose your database objects" screen, expand "Tables" and select "tblDepartment" and "tblEmployee" tables. Set "Model Namespace=Models" and click "Finish"

At this point we should have tblDepartment and tblEmployee entities generated.
a) Change tblDepartment to Department
b) Change tblEmployee to Employee
c) Change tblEmployees nvigation property to Employees
d) Change tblDepartment nvigation property to Department

Build the solution.

Step 3: Right click on the "Controllers" folder and select Add - Controller. Set
Name = EmployeeController
Template = MVC controller with read/write actions and views, using Entity Framework
Model class = Employee(MVCDemo.Models)
Data Context Class = EmployeeContext(MVCDemo.Models)
Views = Razor
after this I m Getting " unable to retrieve metadata for mvc entity data model could not find clr type of tblEmp Entity" this error in dialoug box.Please help me...........




Responses

Posted by: kgovindarao523-21772 on: 2/2/2015 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,
I think the reason for error is, the tables which are going to add to your EDMX must have primary key columns. If not set primary key columns and recheck.

Thank you,
Govind

Justkishor, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Justkishor on: 2/3/2015 [Member] Starter | Points: 25

Up
0
Down
In my EDMX file I have two entity tables Department and Employee are inter related each others and having Entity key both sides as EmployeeId and DeptId.

Justkishor, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response