Working with Entity Framework Core
🗃️ Working with Entity Framework Core
Entity Framework Core (EF Core) is the ORM for .NET Core.
Setting Up:
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Tools
Example Context and Model:
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
}
public class AppDbContext : DbContext
{
public DbSet<Product> Products { get; set; }
}
Run migrations:
dotnet ef migrations add InitialCreate
dotnet ef database update