cloudparts

ent

A Go entity framework from Facebook: describe entities and their edges as Go code, and go generate writes a fully typed client for querying and traversing them in SQL databases.

Linux Foundation project
What it is
Object-relational mapping (full orms)
Type
Open source
Made by
ent project (LF Projects, started at Facebook)
Foundation
The Linux Foundation, joined August 2021. A series of LF Projects, LLC, donated by Facebook (now Meta)
License
Apache 2.0
Facts checked
28 October 2026

What it is

In ent the schema is Go code. Each entity is a type in ent/schema/ with a Fields() method (field.String("name"), field.Int("age").Positive()) and an Edges() method describing relations to other entities, such as edge.To("cars", Car.Type) with an inverse edge.From("owner", User.Type).Ref("cars"). Running go generate ./ent produces a package of plain Go: a client, builders for create, update and delete, typed predicates such as user.AgeGT(30), and query methods for every edge, so client.Group.Query().QueryUsers().QueryCars().Where(car.Model("Ford")).All(ctx) walks from groups to users to cars in one call chain, all checked by the compiler. There are no struct tags, no reflection at run time and no interface{} query strings.

The generated code talks to MySQL, MariaDB, PostgreSQL and SQLite, with TiDB and CockroachDB in preview and Gremlin as an experimental graph backend. Around it sit hooks and interceptors on mutations and queries, privacy policies that run authorisation rules at the data-access layer, eager loading with With…() methods, and extensions that generate a GraphQL server (with gqlgen) or gRPC services from the same schema. Migrations are either automatic, for prototypes, or versioned files planned by Atlas, the schema tool built by ent’s maintainers. The current release is v0.14.6 (March 2026), and commits continued through October 2026.

Why teams pick it

  • Everything is generated and statically typed: renaming a field or edge breaks the build, not production
  • Relations as a graph, with traversals across edges that read like the data model rather than like joins
  • Privacy rules, hooks and interceptors give one place for authorisation, auditing and soft deletes
  • One schema can also generate a GraphQL API, gRPC services and versioned migrations through Atlas

Watch out for

  • Code generation is part of every change: edit the schema, rerun go generate, and commit a large generated package
  • Still versioned 0.x after seven years, and some dialects (TiDB, CockroachDB, Gremlin) are preview or experimental
  • Unusual queries fall back to sql.Selector modifiers or raw SQL, which lose the typed API
  • Opinionated: it wants to own the schema and migrations, which fits new services better than an existing database designed elsewhere

Alternatives

What all full orms have in common →Compare side by side →
Prisma ORMOpen sourceA TypeScript ORM driven by a schema file: you declare models once, Prisma generates a fully typed client and SQL migrations from them, and queries return plain JavaScript objects.jOOQOpen sourceA Java library that models SQL as a type-safe API: a code generator reads your database schema into Java classes, and you write queries against them that the compiler checks.Drizzle ORMOpen sourceA TypeScript library that declares tables in code and queries them through a typed API shaped like SQL, plus a relational API for nested data that always compiles to a single SQL statement.Active Record (Ruby on Rails)Open sourceThe model layer of Ruby on Rails and the best-known implementation of Fowler’s Active Record pattern: each Ruby class wraps a table, each object a row, and objects load, validate and save themselves.Entity Framework CoreOpen sourceMicrosoft’s object-relational mapper for .NET: you query C# classes with LINQ, a DbContext tracks the entities it loads, and SaveChanges writes every change back as SQL through a pluggable database provider.Hibernate ORMOpen sourceThe standard object-relational mapper for Java: it maps annotated classes to tables, tracks changes to loaded objects in a session and writes them back as SQL, and implements Jakarta Persistence (JPA).SQLAlchemyOpen sourceA Python database toolkit in two layers: a SQL expression layer (Core) that builds and runs SQL, and an ORM on top of it that maps classes to tables with an identity map and a unit of work.Tortoise ORMOpen sourceAn async-native Python ORM with a Django-style API: models as classes, await Model.filter(...) queries, and built-in migrations since 1.0.

How it fits with other technologies

A schema with an edge, and a typed traversal over the generated client · go

// ent/schema/user.go
type User struct{ ent.Schema }

func (User) Fields() []ent.Field {
    return []ent.Field{
        field.String("name"),
        field.Int("age").Positive(),
    }
}

func (User) Edges() []ent.Edge {
    return []ent.Edge{edge.To("cars", Car.Type)}
}

// after `go generate ./ent`: everything below is generated and typed
client, _ := ent.Open("postgres", "host=localhost dbname=app sslmode=disable")

a8m := client.User.Create().SetName("a8m").SetAge(30).SaveX(ctx)
client.Car.Create().SetModel("Tesla").SetOwner(a8m).SaveX(ctx)

fords, err := client.User.Query().
    Where(user.AgeGT(25)).
    QueryCars().
    Where(car.Model("Ford")).
    All(ctx)

See it in a real stack

No architecture uses ent yet. Drop it into the playground and wire it up yourself.Open playground →
Where it came from2019–2026

Ariel Mashraki joined Facebook Connectivity’s team in Tel Aviv around 2018, where Go spread from one project to a group of about 15 engineers. Facebook’s internal teams thought about data as a graph of entities and edges, but Go had no graph-based ORM, so he wrote one. Development started against Gremlin on AWS Neptune and later moved to MySQL. Facebook open-sourced it as ent on 3 October 2019, with the principles “Schema As Code”, a statically typed and explicit API generated by codegen, and simple queries, aggregations and graph traversals.

On 31 August 2021 Facebook moved ent to the Linux Foundation, saying a vendor-neutral home would let its maintainers chart its course; by then engineers from GitHub, Mail.ru, Scaleway and Virta Health had contributed. Mashraki and fellow maintainers founded Ariga to build Atlas, which became ent’s migration engine. Development has slowed to occasional releases, the latest being v0.14.6 in March 2026.

Why it’s built this way

Schema as Go code, not struct tags
Types, relations and constraints written in Go can be validated by tools and drive the code generator, instead of hiding in strings.
Generate a typed API rather than reflect at run time
Mashraki wrote that interface{}-based APIs slow developers down, especially newcomers; generated methods and predicates let the compiler catch mistakes.
Model data as a graph
Facebook’s teams already thought in entities and edges, so traversals such as user → groups → users map directly to code.
Keep storage pluggable
The code generator works from templates, so the same schema could target Gremlin first and SQL databases later.

Timeline

  1. 2019

    Facebook open-sources ent (October)

  2. 2021

    Moves to the Linux Foundation (August); Ariga open-sources Atlas (November)

  3. 2024

    v0.14.0 (July)

  4. 2026

    v0.14.6 (March)

Sources11 · facts checked 28 October 2026

Improve this page on GitHub