CodeFluent Entities Importer: Deducing Relationships
Last week we hosted a live webcast – which by the way was recorded and is available here – and following it we had several questions regarding the demo where we created a model from the Northwind database, and especially on how the tool deduced the relationships between entities.
The CodeFluent Entities importer detects foreign keys and transforms them into model relations, so we’re sorry to disappoint so many of you but there is absolutely no magic here!
The importer in fact relies on a database abstraction layer that presents a common interface for all supported databases or modeling systems that can be imported.
Here is a screenshot demonstrating how this intermediary abstraction layer « sees » an « old » Northwind Access Database, prior being imported, in a tool we call « Model and Database Explorer ».
Here you see two foreign keys that will be transformed into relations between entities if this database is imported as a model.
Now, back to magic! Even if there are no foreign keys on tables, the importer is truly capable of casting some voodoo spells
There is a parameter to the importer which is highlighted here:
When this parameter is set to true (the default value), the importer will try to determine automatically relations using column names. For example, say you have two tables like these:
If no foreign key is declared, the importer will « guess » if this is a 1:M or 0:M relation.