# new

open fun new(init: T.() -> Unit): T

Creates a new Entity instance with the fields that are set in the init block. The id will be automatically set.

#### Return

The entity that has been created.

#### Parameters

init

The block where the entity's fields can be set.

#### Samples

org.jetbrains.exposed.v1.tests.shared.entities.EntityTests.testNonEntityIdReference

open fun new(id: ID?, init: T.() -> Unit): T

Creates a new Entity instance with the fields that are set in the init block and with the provided id.

#### Return

The entity that has been created.

#### Parameters

id

The id of the entity. Set this to `null` if it should be automatically generated.

init

The block where the entity's fields can be set.

#### Samples

org.jetbrains.exposed.v1.tests.shared.entities.EntityTests.testNewIdWithGet