Setting Up
Next, we use to invoke the ent code generator to initialize a schema:
Next, let’s add the entproto
package to our project:
In this step, we added two unique fields to our User
entity: name
and . The ent.Schema
is just the definition of the schema. To create usable production code from it we need to run Ent’s code generation tool on it. Run:
At this point, we can open a connection to a database, run a migration to create the users
table, and start reading and writing data to it. This is covered on the Setup Tutorial, so let’s cut to the chase and learn about generating Protobuf definitions and gRPC servers from our schema.