Typing the same using statements in every file? Declare them globally once.
Create GlobalUsings.cs:
// GlobalUsings.cs global using System; global using System.Collections.Generic; global using System.Linq; global using System.Threading.Tasks; global using Microsoft.EntityFrameworkCore;
Now these namespaces are available in ALL files automatically!
Your Other Files:
// ProductService.cs
// No using statements needed!
public class ProductService
{
private readonly ApplicationDbContext _db; // EF Core available
public async Task> GetAllAsync() // Task available
{
return await _db.Products.ToListAsync(); // All available!
}
}
Works in .NET 6+. Huge time saver!
