Your First C# and SQL Server EF Core App - Getting Started with Entity Framework Core



👨‍🏫 Please watch the top 3 most popular videos on my channel.

🥇 33 Million Views : Programming in Visual Basic .Net How to Connect Access Database to VB.NET : https://youtu.be/cwDqjmSmtMQ

🥈 13 Million Views : Visual Basic .Net : Search in Access Database - DataGridView BindingSource Filter (Part 1/2) : https://youtu.be/UoT2oava9ns

🥉 2 Million Views : Visual Basic .Net : Search in Access Database - DataGridView BindingSource Filter (Part 2/2) : https://youtu.be/e5Dvkw7moWg

💰 Donate $29 USD and Receive a free PDF Source Code of the above project:
https://www.paypal.com/paypalme/CodeAMinute/29USD
📧 Contact the instructor via this email: ibasskung@gmail.com

✔ This project is also included: (Export Data To Excel): https://youtu.be/whwQWX4sR7Y


💡 Premium Online Courses 💡
🎓 Master Visual Basic .NET and Access Database By Building the Point Of Sale System (POS)
📲 Enroll Now: https://bit.ly/2WcbRhX

🎓 Learn C# and SQL Server 2019 by Building Windows Forms Application with ADO.NET
📲 Enroll Now: https://bit.ly/37iLrRX

📚 See all courses here: https://bit.ly/2IJPxcm


Step 1: Create a database named 'MyDatabase' in SQL Server Management Studio and create a table named 'Customers'.


Step 2: Inserting data into a Customers table.


Step 3: Create a Windows Forms App project in Visual Studio 2019.


Step 4: Installing NuGet Packages.
1. Microsoft.EntityFrameworkCore.SqlServer 5.0.0

Install-Package Microsoft.EntityFrameworkCore.SqlServer -Version 5.0.0

2. Microsoft.EntityFrameworkCore.Tools 5.0.0

Install-Package Microsoft.EntityFrameworkCore.Tools -Version 5.0.0

Step 5: Creating a Model From the Database.
Creating a Model for an Existing Database using the Scaffold-DbContext command

Scaffold-DbContext "Server=localhost;Database=MyDatabase;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models\db

Step 6: Loading all data from SQL Server into DataGridView!


C# Source Code by iBasskung.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using EFCoreSQLServerDemo.Models.db;

namespace EFCoreSQLServerDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            // Loading all data from SQL Server into DataGridView.
            
            using var db = new MyDatabaseContext();

            var customerData = from c in db.Customers select c;

            if(customerData != null)
            {

                if(customerData.Count() > 0)
                {
                    dataGridView1.DataSource = customerData.ToList();
                }
                else
                {
                    MessageBox.Show("No records found.", "C# SQL Server EF Core 5.0 : iBasskung.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dataGridView1.DataSource = null;
                }

            }

        }
    }
}

Follow me around
✔ Want to get updates on new courses or other cool free stuff? Just follow me on social media if that's your thing!

📺 Pages:
📍 https://www.facebook.com/CodeAMinute
📍 https://www.facebook.com/IbasskungTutorial
📍 https://www.facebook.com/codewithibasskung
📍 https://www.facebook.com/iBasskungAcademy

📺 YouTube:
📍 https://www.youtube.com/c/iBasskung

📺 Udemy:
📍 https://www.udemy.com/user/tanin-sangngam

📺 Twitter:
📍 https://twitter.com/IBasskung

📺 Pinterest:
📍 https://www.pinterest.com/ibasskung

📺 Blogger:
📍 .NET: https://codeaminute.blogspot.com
📍 JAVA: https://javacodeminutes.blogspot.com
📍 VBA: https://vbacodeminutes.blogspot.com

💯 THANK YOU SO MUCH! 💯

#CSharp #EntityFrameworkCore #SQLServer #MasterDetails #CRUDoperation #SearchForm #CustomersForm #iBasskung #WindowsFormApplication #Access #MsAccess #AccessDatabase #MaterialSkin #VisualCSharp #CodeAMinute #iBasskungTutorial #iBasskungAcademy #CodeWithIBasskung #Udemy #OnlineCourses #YouTube #Membership

#VB #VisualBasic #Barcode #QRCode #VisualStudio2019 #MaterialSkin

Keywords / Tags:

visual studio 2019, visual basic 2019, vb.net, vb.net tutorial for beginners visual studio 2019, visual basic, vb, visual studio 2019 visual basic tutorial, visual studio 2019 tutorial, how to use visual studio 2019, visual basic tutorial 2019, access, visual studio, ms access inventory system, ibasskung, inventory management in access, visual basic 2019 tutorial for beginners, programming, visual basic tutorial, access database, visual basic programming, visual basic .net, visual studio 2019 tutorial for beginners, appserv, access vba, download visual studio 2019, how to make an inventory database in access, visual studio 2019 visual basic, ms access, vba access, visual studio 2019 강좌, how to make a program in visual studio 2019, vb.net database tutorial, visual studio 2019 c#, access programming, vb 2019, vb.net 2019, vb.net tutorial, visual basic.net, visual studio 2019 教學, c# hello world visual studio 2019

Comments