Adding a property
Adding a new property to an entity
As the application grows, we will want to add new properties to existing entities let's try doing this and see what happens
Add new property
Replace the student class with the one shown below
namespace EFGetStarted
{
public class Student
{
public int Id { get; set; }
public string Name { get; set; }
public bool IsEnrolled { get; set; }
public string City { get; set; }
}
}
Run the application now with the following code in the program class
using EFGetStarted;
using System;
using System.Linq;
var db = new MyContext();
Console.WriteLine("List of students...\n");
foreach (var s in db.Students)
Console.WriteLine($" Id: {s.Id}\t Name: {s.Name} Is Enrolled: {s.IsEnrolled}");
Console.WriteLine();
Console.WriteLine("Press any key to exit");
Console.ReadKey();
Let us see how to fix this issue next.
Last updated