CodeFirst


public class Student
{
public int StudentId { get; set; }
public string Name { get; set; }
}

public class Course
{
public int CourseId { get; set; }
public string CourseName { get; set; }
}
public class SchoolContext : DbContext
{
public DbSet<Student> Students { get; set; }
public DbSet<Course> Courses { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(@"Server=.\SQLEXPRESS;Database=pasiona;Trusted_Connection=True;");
}
}

Publicado por

Juan Pablo Fuentes

Formador de programación y bases de datos