using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
public static void Main()
public static void RemoveStudent()
TestContext context = new TestContext();
Student student = context.Students.Find(1);
context.Students.Remove(student);
public static void AddStudent()
Student student = new Student();
student.Name = "Dumbledore";
student.Address = new Address();
student.Address.Street = "Test Street";
TestContext context = new TestContext();
context.Students.Add(student);
public int Id { get; set; }
public string Name { get; set; }
[ForeignKey("AddressId")]
public virtual Address Address { get; set; }
public int AddressId { get; set; }
public int Id { get; set; }
public string Street { get; set; }
public class TestContext : System.Data.Entity.DbContext
public DbSet<Student> Students { get; set; }
public DbSet<Address> Addresses { get; set; }