Modify context

Modify the context class

let's modify the context class has shown below, to include the vehicles collection as well

using Microsoft.EntityFrameworkCore;

namespace EFGetStarted
{
    public class MyContext : DbContext
    {        
        public DbSet<Student> Students { get; set; }
        public DbSet<Vehicle> Vehicles { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder options)
        {
            var server = "(localdb)";
            var instance = "mssqllocaldb";
            var database = "CollegeDB";
            var authentication = "Integrated Security = true";

            var conString = $"Data Source={server}\\{instance}; Initial Catalog={database};{authentication}";

            options.UseSqlServer(conString);            
        }
    }
}

Last updated