Available Derived Model Frameworks

When you create a Derived Model, you have to specify which target framework you want to use for the model. The following derived model frameworks are supported and what their specifics are. You can switch target framework at any time.

For more information about the supported derived model frameworks see the Supported Derived Model Frameworks documentation.

Data Transfer Object (DTO) class model

This framework will create:

  • DTO Class model, one file per Root Derived Element.
  • IQueryable based projection code which fetches data using the Entity Model's target framework into DTO classes.
  • Optionally, classes which support projection back from DTO to entity classes to persist changes back to the database using the entity model target framework.

This framework is supported on .NET v4.0 and higher.

Framework attributes

The following attributes are defined by default for this framework:

Root document

  • Serializable
  • DataContract(IsReference$=$true)

Embedded document

  • Serializable
  • DataContract(IsReference$=$true)

Field (all types)

  • DataMember

Framework settings, Project level

The following settings are defined for this framework:

Defaults at the project level

  • Root Derived Element base class name default (string). Default value: empty
  • Embedded Derived Element base class name default (string). Default value: empty

Framework settings, per element

Root document

  • Base class name (string)

Embedded document

  • Base class name (string).

Both base class name settings support the macros {$Name} and {$FullName}.

Presets Defined

The following presets are defined.

  • SD.DTOClasses.ReadOnlyDTOs. This preset generates two VS.NET projects, one with DTO classes, using one file per root derived element and all its embedded derived elements, and one with per root derived element a static class with static projection methods to create a projection from an entity query to the Root Derived Element instance, including nested elements
  • SD.DTOClasses.ReadWriteDTOs. This preset is equal to SD.DTOClasses.ReadOnlyDTOs, but now it also generates static methods create PK filters and to update the originating entity the Root Derived Element was instantiated from.
Info

Only the root entity of the Root Derived Element is updated.

Document Database

The Document Database framework is meant to be used with a document database, where data obtained from the RDBMS, through the supported ORM framework is stored in denormalized form in a document database. This way the document database model can be used as a read-only form of the data in the RDBMS and can be kept in-sync.

Additionally, you can use this framework without the entity model by discarding the code generated for the entity model and solely use the entity model as an abstract entity model and theoretical basis for the derived model and its classes. In this case you only use the generated DTO classes and the optional document database setup/usage code to work with the document database client.

This framework will create:

  • DTO Class model, one file per Root Derived Element.
  • IQueryable based projection code which fetches data using the Entity Model's target framework into DTO classes.
  • For the Document database chosen (through the preset), optionally, a set of classes for setting up/using the Document database's client.

The framework will validate Root Derived Elements on whether they have an ID field present. If not, an error is raised.

This framework is supported on .NET 4.0 or higher, but it depends on the client of the target database whether the target document database presets are available for .NET 4.0 or that .NET 4.5 or higher has to be chosen.

Framework settings

The settings for this framework are equal to the DTO Class model framework.

Presets defined

The following presets are defined.

  • SD.RavenDB. This is the preset to be used for the RavenDB document database. It generates one VS.NET project with DTO classes, using one file per root derived element and all its embedded derived elements.
  • SD.MongoDB. This is the preset to be used for the MongoDB document database. It uses the official MongoDB C# driver, using v2.x syntax. It generates two VS.NET projects: one with DTO classes, using one file per root derived element and all its embedded derived elements, and one with Bson class mappings, including inheritance definitions.
  • SD.GenericDocDB. This is the preset to be used for a variety of document databases which have in general the same requirements for the DTO/document classes, e.g. RethinkDB, Microsoft DocumentDB and others. It generates one VS.NET project with DTO classes, using one file per root derived element and all its embedded derived elements. It adds a JsonProperty("id") attribute on the ID field in the Root Derived Element class.