---
title: "Scaffolding error in asp.net mvc?"  
description: "Scaffolding error in asp.net mvc?"  
author: "Elena Glibart"  
published: 2014-11-10  
updated: 2014-11-10  
canonical: https://www.mindstick.com/forum/2551/scaffolding-error-in-asp-dot-net-mvc  
category: "asp.net mvc"  
tags: ["asp.net", "controller"]  
reading_time: 2 minutes  

---

# Scaffolding error in asp.net mvc?

I'm going in circles with either an in valid [context](https://www.mindstick.com/forum/23245/what-is-context-in-android) type or undefined [entity](https://www.mindstick.com/forum/160562/database-connectivity-using-entity-framework-database-first-approach) key. I have attached a [copy](https://www.mindstick.com/forum/161993/explain-the-numpy-array-copy-vs-view-with-example) of the longer [error message](https://www.mindstick.com/forum/23174/error-message-the-page-you-are-requesting-cannot-be-served-because-of-the-extension-configuration). Just [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to create a [test](https://yourviews.mindstick.com/story/1427/explosive-facts-about-trinity-test-world-s-first-nuclear-bomb) [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) that is [connected](https://www.mindstick.com/articles/12941/link-building-and-search-engine-rankings-how-are-they-connected) to an existing db.\
![Scaffolding error in asp.net mvc?](https://www.mindstick.com/mindstickforums/c68bb2ac-ae92-405b-914a-cd8054fb649f/images/679f1e12-1b95-4ee5-9dd1-9c88afade124.png)\
\

Here is the code - thanks in advance

```
    public class TestPerson{    int ID { get; set; }    string FirstName { get; set; }    string LastName { get; set; }    string Hair { get; set; }    string Race { get; set; }    string Measurements { get; set; }}public class TestPersonContext : DbContext{    public DbSet<TestPerson> TestPersons { get; set; }}
```

## Replies

### Reply by Anonymous User

You should set one of your properties as the primary key. In your case this will be the ID property:

```
public class TestPerson{    [Key]    public int ID { get; set; }    public string FirstName { get; set; }    public string LastName { get; set; }    public string Hair { get; set; }    public string Race { get; set; }    public string Measurements { get; set; }}public class TestPersonContext : DbContext{    public DbSet<TestPerson> TestPersons { get; set; }}
```

Btw why are all your properties private? It would be recommended to make all them publicly available, especially the primary key.

What is more there is something called Convention over Configuration which is used quite intensively in Entity Framework. One of the conventions is the Primary Key Convention which states:


---

Original Source: https://www.mindstick.com/forum/2551/scaffolding-error-in-asp-dot-net-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
