func (bpc *BlogPostCreate) Save(ctx context.Context) (*BlogPost, error) {
	var (
		err  error
		node *BlogPost
	)
	if len(bpc.hooks) == 0 {
		if err = bpc.check(); err != nil {
			return nil, err
		}
		node, err = bpc.sqlSave(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*BlogPostMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			if err = bpc.check(); err != nil {
				return nil, err
			}
			bpc.mutation = mutation
			if node, err = bpc.sqlSave(ctx); err != nil {
				return nil, err
			}
			mutation.id = &node.ID
			mutation.done = true
			return node, err
		})
		for i := len(bpc.hooks) - 1; i >= 0; i-- {
			if bpc.hooks[i] == nil {
				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
			}
			mut = bpc.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, bpc.mutation); err != nil {
			return nil, err
		}
	}
	return node, err
}
Save creates the BlogPost in the database.
package ent
import (
	"context"
	"errors"
	"fmt"
	"entgo.io/contrib/entproto/internal/entprototest/ent/blogpost"
	"entgo.io/contrib/entproto/internal/entprototest/ent/category"
	"entgo.io/contrib/entproto/internal/entprototest/ent/user"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
)
type BlogPostCreate struct {
	config
	mutation *BlogPostMutation
	hooks    []Hook
}
func (bpc *BlogPostCreate) SetTitle(s string) *BlogPostCreate {
	bpc.mutation.SetTitle(s)
	return bpc
}
func (bpc *BlogPostCreate) SetBody(s string) *BlogPostCreate {
	bpc.mutation.SetBody(s)
	return bpc
}
func (bpc *BlogPostCreate) SetExternalID(i int) *BlogPostCreate {
	bpc.mutation.SetExternalID(i)
	return bpc
}
func (bpc *BlogPostCreate) SetAuthorID(id int) *BlogPostCreate {
	bpc.mutation.SetAuthorID(id)
	return bpc
}
func (bpc *BlogPostCreate) SetNillableAuthorID(id *int) *BlogPostCreate {
	if id != nil {
		bpc = bpc.SetAuthorID(*id)
	}
	return bpc
}
func (bpc *BlogPostCreate) SetAuthor(u *User) *BlogPostCreate {
	return bpc.SetAuthorID(u.ID)
}
func (bpc *BlogPostCreate) AddCategoryIDs(ids ...int) *BlogPostCreate {
	bpc.mutation.AddCategoryIDs(ids...)
	return bpc
}
func (bpc *BlogPostCreate) AddCategories(c ...*Category) *BlogPostCreate {
	ids := make([]int, len(c))
	for i := range c {
		ids[i] = c[i].ID
	}
	return bpc.AddCategoryIDs(ids...)
}
func (bpc *BlogPostCreate) Mutation() *BlogPostMutation {
	return bpc.mutation
}