CodeFluent Entities: Basic Tips To Lower Generation Time
First let’s start with some metrics. For this post I created 4 models:
- Sample10 containing 10 entities of 10 properties,
- Sample100 containing 100 entities of 10 properties,
- Sample300 containing 300 entities of 10 properties,
- Sample500 containing 500 entities of 10 properties
Screenshot of the Sample500 default surface
Furthermore, each model has the same two producers configured:
- The SQL Server Producer,
- And the Business Object Model Producer.
Note: A producer is a code generator translating the platform independent model you designed into scripts (e.g. T-SQL, PL/SQL), code (e.g. C#, VB.NET), services (e.g. ASMX, WCF) or UIs (e.g. SharePoint Web Parts, ASP.NET).
Finally, I’ve got a local SQL Server 2008 which my SQL Server targets and I’m generating the .NET Business Object Model in C#.
Now, keeping the default settings and generating each model from scratch using CodeFluent Entities (generate the persistence scripts, create the database, deploy them and generate the .NET API) takes:
- 9 seconds for Sample10
- 44 seconds for Sample100
- 3 minutes 2 seconds for Sample300
- 6 minutes 11 seconds for Sample500
Here are a few tips to lower generation time.
Set “Create Default Application” to “False”
By default, CodeFluent Entities infers a “virtual application” from your model: forms and grids will be created to display and edit each of your entities, resources to display text, screens to call methods, etc.
Therefore, if you’re not generating the UI or are not currently working on it, disabling the creation of this default application will save you a whole lot of time.
To do this:
- In the solution explorer select your CodeFluent Entities project,
- and either from the property grid or from the project properties panel set the “Create Default Application” property to “False”.
Generate over again and the generation process should be much faster. For example:
- Generating Sample300 drops to 2 minutes 10 seconds: we gained 52 seconds (28.5% gain)
- Generating Sample500 drops to 2 minutes 51 seconds: we gained 3 minutes 20 seconds (53.9% gain)
Consequently, if not working on the generated UI or simply not using it, disabling this feature will save you a lot of time
Disabling Producers You Are Not Using
Frequently when building your app, you’ll be doing just a little change here and there such as modifying a validation rule which only impacts the .NET class, or a method body which only impacts a stored procedure. In such cases, if your application is pretty big, a way to gain time is to disable unnecessary producers before generating over again.
For instance, if my change in the model only impacted .NET classes, let’s just disable the SQL Server Producer, so that I’m skipping the persistence layer update:
This will for sure save me some time.
Note: another point of interest is that CodeFluent Entities projects can have different producers enabled/disabled by configurations (see project properties, Build panel).
This way you could have several configurations (e.g. Persistence Dev, .NET Dev, UI Dev) with just the producers you need enabled in each one of them, and then switch from one another when needed.
Hope this helps,