func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
	if _, ok := c.driver.(*txDriver); ok {
		return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
	}
	tx, err := c.driver.(interface {
		BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
	}).BeginTx(ctx, opts)
	if err != nil {
		return nil, fmt.Errorf("ent: starting a transaction: %w", err)
	}
	cfg := c.config
	cfg.driver = &txDriver{tx: tx, drv: c.driver}
	return &Tx{
		config:                 cfg,
		BlogPost:               NewBlogPostClient(cfg),
		Category:               NewCategoryClient(cfg),
		DependsOnSkipped:       NewDependsOnSkippedClient(cfg),
		DuplicateNumberMessage: NewDuplicateNumberMessageClient(cfg),
		ExplicitSkippedMessage: NewExplicitSkippedMessageClient(cfg),
		Image:                  NewImageClient(cfg),
		ImplicitSkippedMessage: NewImplicitSkippedMessageClient(cfg),
		InvalidFieldMessage:    NewInvalidFieldMessageClient(cfg),
		MessageWithEnum:        NewMessageWithEnumClient(cfg),
		MessageWithFieldOne:    NewMessageWithFieldOneClient(cfg),
		MessageWithID:          NewMessageWithIDClient(cfg),
		MessageWithOptionals:   NewMessageWithOptionalsClient(cfg),
		MessageWithPackageName: NewMessageWithPackageNameClient(cfg),
		Portal:                 NewPortalClient(cfg),
		User:                   NewUserClient(cfg),
		ValidMessage:           NewValidMessageClient(cfg),
	}, nil
}
BeginTx returns a transactional client with specified options.
package ent
import (
	"context"
	"fmt"
	"log"
	"entgo.io/contrib/entproto/internal/entprototest/ent/migrate"
	"github.com/google/uuid"
	"entgo.io/contrib/entproto/internal/entprototest/ent/blogpost"
	"entgo.io/contrib/entproto/internal/entprototest/ent/category"
	"entgo.io/contrib/entproto/internal/entprototest/ent/dependsonskipped"
	"entgo.io/contrib/entproto/internal/entprototest/ent/duplicatenumbermessage"
	"entgo.io/contrib/entproto/internal/entprototest/ent/explicitskippedmessage"
	"entgo.io/contrib/entproto/internal/entprototest/ent/image"
	"entgo.io/contrib/entproto/internal/entprototest/ent/implicitskippedmessage"
	"entgo.io/contrib/entproto/internal/entprototest/ent/invalidfieldmessage"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithenum"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithfieldone"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithid"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithoptionals"
	"entgo.io/contrib/entproto/internal/entprototest/ent/messagewithpackagename"
	"entgo.io/contrib/entproto/internal/entprototest/ent/portal"
	"entgo.io/contrib/entproto/internal/entprototest/ent/user"
	"entgo.io/contrib/entproto/internal/entprototest/ent/validmessage"
	"entgo.io/ent/dialect"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
)
type Client struct {
	config
	Schema *migrate.Schema
	BlogPost *BlogPostClient
	Category *CategoryClient
	DependsOnSkipped *DependsOnSkippedClient
	DuplicateNumberMessage *DuplicateNumberMessageClient
	ExplicitSkippedMessage *ExplicitSkippedMessageClient
	Image *ImageClient
	ImplicitSkippedMessage *ImplicitSkippedMessageClient
	InvalidFieldMessage *InvalidFieldMessageClient
	MessageWithEnum *MessageWithEnumClient
	MessageWithFieldOne *MessageWithFieldOneClient
	MessageWithID *MessageWithIDClient
	MessageWithOptionals *MessageWithOptionalsClient
	MessageWithPackageName *MessageWithPackageNameClient
	Portal *PortalClient
	User *UserClient
	ValidMessage *ValidMessageClient
}
func NewClient(opts ...Option) *Client {
	cfg := config{log: log.Println, hooks: &hooks{}}
	cfg.options(opts...)
	client := &Client{config: cfg}
	client.init()
	return client
}
func (c *Client) init() {
	c.Schema = migrate.NewSchema(c.driver)
	c.BlogPost = NewBlogPostClient(c.config)
	c.Category = NewCategoryClient(c.config)
	c.DependsOnSkipped = NewDependsOnSkippedClient(c.config)
	c.DuplicateNumberMessage = NewDuplicateNumberMessageClient(c.config)
	c.ExplicitSkippedMessage = NewExplicitSkippedMessageClient(c.config)
	c.Image = NewImageClient(c.config)
	c.ImplicitSkippedMessage = NewImplicitSkippedMessageClient(c.config)
	c.InvalidFieldMessage = NewInvalidFieldMessageClient(c.config)
	c.MessageWithEnum = NewMessageWithEnumClient(c.config)
	c.MessageWithFieldOne = NewMessageWithFieldOneClient(c.config)
	c.MessageWithID = NewMessageWithIDClient(c.config)
	c.MessageWithOptionals = NewMessageWithOptionalsClient(c.config)
	c.MessageWithPackageName = NewMessageWithPackageNameClient(c.config)
	c.Portal = NewPortalClient(c.config)
	c.User = NewUserClient(c.config)
	c.ValidMessage = NewValidMessageClient(c.config)
}
func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
	switch driverName {
	case dialect.MySQL, dialect.Postgres, dialect.SQLite:
		drv, err := sql.Open(driverName, dataSourceName)
		if err != nil {
			return nil, err
		}
		return NewClient(append(options, Driver(drv))...), nil
	default:
		return nil, fmt.Errorf("unsupported driver: %q", driverName)
	}
}
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
	if _, ok := c.driver.(*txDriver); ok {
		return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
	}
	tx, err := newTx(ctx, c.driver)
	if err != nil {
		return nil, fmt.Errorf("ent: starting a transaction: %w", err)
	}
	cfg := c.config
	cfg.driver = tx
	return &Tx{
		ctx:                    ctx,
		config:                 cfg,
		BlogPost:               NewBlogPostClient(cfg),
		Category:               NewCategoryClient(cfg),
		DependsOnSkipped:       NewDependsOnSkippedClient(cfg),
		DuplicateNumberMessage: NewDuplicateNumberMessageClient(cfg),
		ExplicitSkippedMessage: NewExplicitSkippedMessageClient(cfg),
		Image:                  NewImageClient(cfg),
		ImplicitSkippedMessage: NewImplicitSkippedMessageClient(cfg),
		InvalidFieldMessage:    NewInvalidFieldMessageClient(cfg),
		MessageWithEnum:        NewMessageWithEnumClient(cfg),
		MessageWithFieldOne:    NewMessageWithFieldOneClient(cfg),
		MessageWithID:          NewMessageWithIDClient(cfg),
		MessageWithOptionals:   NewMessageWithOptionalsClient(cfg),
		MessageWithPackageName: NewMessageWithPackageNameClient(cfg),
		Portal:                 NewPortalClient(cfg),
		User:                   NewUserClient(cfg),
		ValidMessage:           NewValidMessageClient(cfg),
	}, nil
}