T.Pilvelis T.Pilvelis - 2 months ago 13
ASP.NET (C#) Question

EntityType ' ' has no key defined

So I have been following this tutorial on ASP.NET. I have created a Model and intend on generating a Controller with views, using Entity Framework. However I have been stuck on this error for nearly hours researching causes and its only 2 lines of code and I can't for the life of me understand how I am getting this error.

Link to Tutorial https://mva.microsoft.com/en-US/training-courses/introduction-to-asp-net-mvc-8322?l=Omf358Zy_1604984382
This is all the code I have written
Receiving this message


Here we go:

You should to add the [KEY] attribute for your TaskID like this code:

public class Tasks
 public int TaskID {get;set;}
 public string taskStatus {get;set;}

Hope it helps;)