I have two types of entities: an employee entity and an office entity, with a one to many relationship between the two such that there are many employees for one office. For
You might consider a generic class like so:
public class GenericRepository where T : class
{
internal YourConext context;
internal DbSet dbSet;
public GenericRepository(YourContext context)
{
this.context = context;
this.dbSet = context.Set();
}
public virtual void Insert(T entity)
{
dbSet.Add(entity);
context.SaveChanges();
}
}