
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.
- 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.Selectormodifiers 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 →
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.DbContext tracks the entities it loads, and SaveChanges writes every change back as SQL through a pluggable database provider.
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.
Timeline
Sources11 · facts checked 28 October 2026
- ent docs: Getting started (schema, `go generate`, edges, traversals, migrations with Atlas)
- ent docs: Supported dialects (MySQL, MariaDB, PostgreSQL, SQLite; TiDB and CockroachDB preview; Gremlin experimental)
- ent docs: Privacy
- ent docs: Hooks
- ent docs: Interceptors
- ent docs: Eager loading
- ent docs: GraphQL integration
- ent docs: gRPC integration (entproto)
- ent docs: Versioned migrations
- GitHub: ent/ent (Apache 2.0, commits through October 2026)
- Linux Foundation blog: Ent joins the Linux Foundation (31 August 2021)