Integrating your Custom Producer to the Modeler
Creating your own custom producers in CodeFluent Entities is pretty straightforward: all you have to do is implement the IProducer interface. This interface contains three methods:
- Initialize, which takes as a parameter an instance of the CodeFluent Entities project and the current producer
When using CodeFluent Entities directly from the command line via its CodeFluent.Build.exe, nothing special was required: declare a producer element as usual and set the typeName attribute of the producer element to your IProducer implementation. But what about integrating to the Modeler? Well it’s just as easy!
First, open Visual Studio and in Tools > Options… > CodeFluent Entities, select the advanced view using the advanced button at the top of the property grid. As you can see, there’s a property named “Custom Configuration File Path” which points to a Custom.config file.
By default, this file doesn’t exist, get to the pointed directory and create this Custom.config file with the following content:
<producerDescriptor name="MyProducer" displayName="MyProducer" category="MyStuff" typeName="CodeFluent.Producers.CodeDom.EntityFrameworkProducer, CodeFluent.Producers.CodeDom" />
As you can see, we’re adding a producer descriptor named “MyProducer” in the “MyStuff” category, and this producer points to the EntityFrameworkProducer provided in the CodeFluent.Producers.CodeDom assembly.
If you create a new CodeFluent Entities project and add a new producer to your project, you’ll now see:
Voilà! The “MyProducer” was added to the “MyStuff” category and you can now use your own custom producer just as any other producer