In this tutorial, I'll show you how to load data from database into DataGridView using Entity Framework in VB.NET

As you know, DataGridView control provides a powerful and flexible way to display data in a tabular format. You can use the DataGridView control to show read-only views of a small amount of data, or you can scale it to show editable views of very large sets of data.

To practice demo, we will create a new VB.NET Project, then add an entity framework model as shown below

entity framework vb.net

enter your model name

vb.net entity framework

Select EF Designer from database, then click Next.

ef vb.net

Select version Entity Framework that you want to use, click Next

entity framework using vb.net

Select your table that you want to use, then enter your model namespace.

We will use Northwind database to play demo, you should read how to download and restore northwind database to sql server

Add a DataGridView control to your windows form application, then add a BindingSource to your DataGridView

vb.net windows forms

Add code to handle Form_Load event as the following

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim db As New NorthwindEntities
        EmployeeBindingSource.DataSource = db.Employees.ToList()
    End Sub
End Class

Run your project

windows forms entity framework using vb.net