ELI5: Ent – Schema as Code in Go

In this post we take a closer look at an open source project called Ent, an entity framework for Go, in a way that is very easy to understand or as it is commonly known online, ELI5. If you’d like to learn by watching or listening, watch a video about this open source project on our Facebook Open Source YouTube channel.


What are most of the applications doing these days? They interact with data in one way or another. As your app grows, it becomes more difficult to manage databases, schemas, queries, and restrictions. These challenges are why a technique called Object-Relational Mapping (ORM) was created. It greatly simplifies the development of your app by restricting the work with raw SQL, making your database more secure, your code less repetitive and your app more robust.

At Facebook, we tend to think about data modeling in graphics concepts like GraphQL, a query language for API. While working with Go-lang, we had been looking for a way to take advantage of ORM when interacting with graph-based data models. That search led us to create a new open source project, Ent.

Ent is an entity framework that was developed for the Go programming language. This framework offers developers a graphical, object-relational mapping.

With Ent, data schemas, including types, relationships, and constraints, are treated as code. With Ent, developers can avoid changing contexts and continue working with Go while using Go.

Ent’s static types and explicit API make it very accessible to new developers. In turn, this increased efficiency leads to a more robust code.

Ent is very declarative in keeping operations like queries, aggregations, and chart iterations simple, as there is no need to write raw SQL.

Ultimately, Ent enforces a memory-agnostic approach where its users are not tied to any particular technology. For example, during the development of Ent, the Facebook Connectivity team was able to migrate seamlessly from AWS Neptune to MySQL.

Where is it used?

Ent was open source in 2019 and was actively used by the Facebook Connectivity team and several external projects.

Where can i learn more?

Want to learn more about Ent? The project has excellent starter and advanced documentation, as well as a growing fan base on GitHub. If you want to use Go, we invite you to take a look at GoDoc.

If you have any thoughts or questions about Ent, please let us know on our YouTube channel or tweet us at.

About the ELI5 series

In a series of short videos (around 1 minute long) one of our developer attorneys on the Facebook Open Source team explains a Facebook Open Source project in a way that is easy to understand and use.

For each of these videos we are writing an accompanying blog post (like the one you are reading right now) that you can find on our YouTube channel.

To learn more about Facebook Open Source, visit our Open Source website, subscribe to our YouTube channel, or follow us on Twitter and Facebook.

Would you like to work with open source on Facebook? Check out our open source related job postings on our careers page by taking this short survey.

Comments are closed.