> For the complete documentation index, see [llms.txt](https://bxorm.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bxorm.ortusbooks.com/reference/built-in-functions/entitynew.md).

# EntityNew

Instantiate a new entity, optionally with a struct of properties.

## Method Signature

```
EntityNew(entityName=[String], properties=[Struct], ignoreExtras=[Boolean])
```

### Arguments

| Argument       | Type      | Required | Description                                                                                                    | Default |
| -------------- | --------- | -------- | -------------------------------------------------------------------------------------------------------------- | ------- |
| `entityName`   | `String`  | `true`   | The name of the entity to create.                                                                              |         |
| `properties`   | `Struct`  | `false`  | A struct of properties to populate on the new entity.                                                          |         |
| `ignoreExtras` | `Boolean` | `false`  | If false, an error will be thrown if properties are provided that do not exist on the entity. Not implemented. |         |

## Examples

### Creating Simple Entities

Creating an instance of an ORM entity is as simple as calling `entityNew()` with the name of the entity you wish to create. For example, to create a new instance of an entity named `Auto`, you would do the following:

```java
var myEntity = entityNew( "Auto" );
```

To populate the entity with initial values, you can pass a struct of properties as the second argument:

```java
var myEntity = entityNew( "Auto", {
    Make = "Toyota",
    Model = "Camry",
    Year = 2020
} );
```

### Ignoring Extra Properties

(Coming soon) By default, `ignoreExtra` is set to `false`, meaning that if you provide properties that do not exist on the entity, an error will be thrown.

For example, this will throw an error if `Color` is not a defined property on the `Auto` entity:

```java
var myEntity = entityNew( "Auto", {
    Make = "Toyota",
    Model = "Camry",
    Year = 2020,
    Color = "Blue"
}, true );
```

To change this behavior, you can set the `ignoreExtra` argument to `true`:

```java
var myEntity = entityNew( "Auto", {
    Make = "Toyota",
    Model = "Camry",
    Year = 2020,
    Color = "Blue"
}, true );
```

This will create the entity and ignore the `Color` property if it does not exist on the `Auto` entity.

## Related

* [EntityDelete](/reference/built-in-functions/entitydelete.md)
* [EntityIsAttached](/reference/built-in-functions/entityisattached.md)
* [EntityLoad](/reference/built-in-functions/entityload.md)
* [EntityLoadByExample](/reference/built-in-functions/entityloadbyexample.md)
* [EntityLoadByPK](/reference/built-in-functions/entityloadbypk.md)
* [EntityMerge](/reference/built-in-functions/entitymerge.md)
* [EntityNameArray](/reference/built-in-functions/entitynamearray.md)
* [EntityNameList](/reference/built-in-functions/entitynamelist.md)
* [EntityReload](/reference/built-in-functions/entityreload.md)
* [EntitySave](/reference/built-in-functions/entitysave.md)
* [EntityToQuery](/reference/built-in-functions/entitytoquery.md)
* [ORMClearSession](/reference/built-in-functions/ormclearsession.md)
* [ORMCloseAllSessions](/reference/built-in-functions/ormcloseallsessions.md)
* [ORMCloseSession](/reference/built-in-functions/ormclosesession.md)
* [ORMEvictCollection](/reference/built-in-functions/ormevictcollection.md)
* [ORMEvictEntity](/reference/built-in-functions/ormevictentity.md)
* [ORMEvictQueries](/reference/built-in-functions/ormevictqueries.md)
* [ORMExecuteQuery](/reference/built-in-functions/ormexecutequery.md)
* [ORMFlush](/reference/built-in-functions/ormflush.md)
* [ORMFlushAll](/reference/built-in-functions/ormflushall.md)
* [ORMGetHibernateVersion](/reference/built-in-functions/ormgethibernateversion.md)
* [ORMGetSession](/reference/built-in-functions/ormgetsession.md)
* [ORMGetSessionFactory](/reference/built-in-functions/ormgetsessionfactory.md)
* [ORMReload](/reference/built-in-functions/ormreload.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://bxorm.ortusbooks.com/reference/built-in-functions/entitynew.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
