# Other .NET Programming > Windows Presentation Foundation (WPF) & XAML forum >  Add rows and columns at runtime and update values to database

## dhirajsakariya

Hi there, I have created Entity models. I would like to design a xaml in wfp to insert and update records like spreadsheet.
i have attached sample entities and screenshot. Here Column represents : Subject and total Marks Rows represents : class Section and students Cell is to update marks objects in that particular subject by students 

How can I add Subject(column) at run time and save it to database?

How can I Standard, ClassSection and student and their mark (Rows) in grid and save it to database?

Can anyone suggest the approach?





```
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace School.Model
{

    public class SchoolContext : DbContext
    {
        public DbSet<Standard> Standards { get; set; }
        public DbSet<Subject> Subjects { get; set; }
        public DbSet<ClassSection> ClassSections { get; set; }
        public DbSet<Student> Students { get; set; }

        public DbSet<Result> Results { get; set; }
    }
   public  class Standard
    {
        [Key]
        public int Id { get; set; }
        public string Name { get; set; }

        public ICollection<Subject> Subjects { get; set; }
        public ICollection<ClassSection> ClassSections { get; set; }

    }

    public class Subject
    {
        [Key]
        public int Id { get; set; }

        public string Name { get; set; }

        public int TotalMarks { get; set; }

        public int? StandardId { get; set; }

        public virtual Standard Standard { get; set; }

        public ICollection<Result> Results { get; set; }
    }

    public class ClassSection
    {
        [Key]
        public int Id { get; set; }

        public string Name { get; set; }


        public int? StandardId { get; set; }

        public virtual Standard Standard { get; set; }
        public ICollection<Student> Students { get; set; }
    }

    public class Student
    {
        [Key]
        public int Id { get; set; }

        public string Name { get; set; }


        public int? ClassSectionId { get; set; }

        public virtual ClassSection ClassSection { get; set; }
        public ICollection<Result> Results { get; set; }
    }

    public class Result
    {
        [Key]
        public int Id { get; set; }

        public int SubjectId { get; set; }
        public int StudentId { get; set; }

        public int ObtainedMarks { get; set; }

        public virtual Subject Subject { get; set; }
        public virtual Student Student { get; set; }

    }
}
```

----------

