- Motivation
- Holds details of object-relational mapping in metadata in-order to create loosely coupled Mappers
- Summary
- A Metadata Mapping allows developers to define
the mappings in a simple tabular form, which can then be processed by generic
code to carry out the details of reading, inserting, and updating the data.
- Mapping can be implemented in two ways code generation and reflective programming.
- Code generation is a less dynamic approach since any changes to the mapping
require recompiling and redeploying at least that part of the software.
- With a
reflective approach, you can just change the mapping data file and the existing
classes will use the new metadata.
- On most occasions you keep the metadata in a separate file format. These days
XML is a popular choice as it provides hierarchic structuring while freeing you
from writing your own parsers and other tools.
- Metadata Mapping can interfere with refactoring,
particularly if you're using automated tools but On the other hand, Metadata Mapping can make
refactoring the database easier,
A typical metadata mapping pattern | Metadata mapping using Entity framework | | |
- When to Use
- When implementing ORM based solution.
- Usually we don`t need to handcraft this solution because most of popular ORM solution like Entity Framework (EF) support it out of the box.
- References
- http://martinfowler.com/eaaCatalog/metadataMapping.html
|
|