Simple MVC and Razor with Database Connection for Simple Insert, Update and Delete.

Model View Controller

If you are new in MVC (Model View Controller) then this tutorial is the ideal for you. I had issues in finding one single tutorial with all my questions so I decided to put one together myself. This tutorial might seem long however, most of the tutorials is full of images to help you visualize better so in order words, it is not as long as it might look like on your scroll bar 😉 Goodluck and hope you find no issues… if you do, feel free to leave a comment and I will be glad to help where possible.

Continue reading

Error: system.data.entity.edm.edm entitytype entity type has no key defined

Cause: 

No Primary Key is defined. Visual Studio generally looks out for an entityproperty int ID or similar and set it as a primary key. However, if our primary key is something like “Username” then we need to specify which one it is.

 

Solution:

Include the namespace:

using System.ComponentModel.DataAnnotations;

Before your Primary Key add the following attribute:

[Key]