Tutorials Entity Framework Core Tutorial
CRM Database with EF Core
CRM Database with EF Core: free step-by-step lesson with examples, common mistakes, and interview tips — part of Entity Framework Core Tutorial on Toolliyo Academy.
On this page
Entity Framework Core Tutorial · Lesson 96 of 100
CRM Database with EF Core
Beginner ✓ → Intermediate ✓ → Advanced ✓ → Professional
Professional · 4 — Real projects · ~10 min · Module 10: Real-World Projects
What is this?
CRM databases track leads, contacts, accounts, activities, and deals — EF supports pipeline stages and linking contacts to ShopNest Customer for B2B sales.
Why should you care?
ShopNest B2B team manages wholesale leads before they become Customer accounts — CRM schema captures pre-sale interactions.
See it live — copy this example
Paste into a .NET project with EF Core packages, then run with LocalDB/SQL Server (dotnet ef / dotnet run).
public class Lead { public int Id { get; set; } public string Company { get; set; } = ""; public string Stage { get; set; } = "New"; public decimal EstimatedValue { get; set; } }
public class Activity { public int Id { get; set; } public int LeadId { get; set; } public string Type { get; set; } = "Call"; public DateTime At { get; set; } public string Notes { get; set; } = ""; }
var pipeline = await db.Leads
.GroupBy(l => l.Stage)
.Select(g => new { Stage = g.Key, Count = g.Count(), Value = g.Sum(l => l.EstimatedValue) })
.ToListAsync();
What happened?
- Lead has Stage for pipeline.
- GroupBy aggregates deal count and value per stage for sales dashboard — single SQL aggregation.
Practice next
- Model Lead, Activity, and optional link Lead.ConvertedCustomerId.
- Index Stage for pipeline queries.
- Log Activity on every sales touchpoint.
- Add Deal entity with expected CloseDate and probability.
- Query leads with no activity in 30 days for follow-up job.
Remember
CRM: Lead, Activity, pipeline Stage. GroupBy powers funnel metrics. Convert lead to Customer at win.
ShopNest B2B pipeline
Sales ops dashboard Groups Leads by Stage for weekly standup using EF aggregation.
Outcome: Leadership sees pipeline value without Excel exports from SQL.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!