Dealing with DB Through EF within Winforms I have the following code which uses EntityFramework to reach out to a DB and retrieve data to populate into a Winform application gridview.

I am still quite new to C# and especially abstracting code out of code behind/writing loosely coupled code.

Could the following code be reviewed and feedback given on the methods I am using to construct the application in a methodical way?

MainScreenForm

public partial class MainScreenForm : MainScreenController
{
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

    public MainScreenForm()
    {
        InitializeComponent();
    }

    private void MainScreenForm_Load(object sender, EventArgs e)
    {
        log.Debug("Main Screen Launched");
        PopulateGrid();
        AdjustGridviewVisuals();
    }

    private void AdjustGridviewVisuals()
    {
        metroGrid1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        metroGrid1.AllowUserToAddRows = false;
        metroGrid1.RowHeadersVisible = false;

        this.metroGrid1.Columns["Id"].Visible = false;
        this.metroGrid1.Columns["ExamId"].Visible = false;
        this.metroGrid1.Columns["Comments"].Visible = false;
        this.metroGrid1.Columns["CreationDate"].Visible = false;
        this.metroGrid1.Columns["LastModified"].Visible = false;
        this.metroGrid1.Columns["PatientState"].Visible = false;
    }

    private void PopulateGrid()
    {
        metroGrid1.DataSource = GetListOfPatients();
    }
}


MainScreen Controller

public class MainScreenController : MetroForm
{
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

    private TrollyPatientDbContext db = new TrollyPatientDbContext();

    public List&lt;Patient&gt; GetListOfPatients()
    {
        log.Debug("Attempting to retreve a list of patients from SQL");
        var patients = db.Patients;
        return patients.ToList();
    }
}


DbContext

public class TrollyPatientDbContext : DbContext
{
    public TrollyPatientDbContext() : base("PrimaryConnection")
    {
    }
    public DbSet&lt;Exam&gt; Exams { get; set; }
    public DbSet&lt;Patient&gt; Patients { get; set; }
}


The models are just standard "POCO" (I think that's what it is called).

Is the way I have extended the controller to allow access to methods within it a good way to do this work or should I being using static methods instead?

Is this considered a way of constructing to an MVP practice?
this.metroGrid1.Columns["Id"].Visible = false;
    this.metroGrid1.Columns["ExamId"].Visible = false;
    this.metroGrid1.Columns["Comments"].Visible = false;
    this.metroGrid1.Columns["CreationDate"].Visible = false;
    this.metroGrid1.Columns["LastModified"].Visible = false;
    this.metroGrid1.Columns["PatientState"].Visible = false;



These lines have a lot of repetition. It would be better to create an array of the column names, and then loop over the array and set each one.


    var patients = db.Patients;



What's the purpose of having a temporary variable here? You're not even declaring its type.