Home > Developing Using CodeFluent Entities > What is a CodeFluent Entities model?

What is a CodeFluent Entities model?


CodeFluent Entities is a unique product integrated into Visual Studio 2008/2010/vNext which allows you to generate components such as scripts (e.g. T-SQL, PL/SQL), code (e.g. C#, VB), web services (e.g. WCF, ASMX) and UIs (e.g. ASP.NET, SharePoint, WPF).

The code generation process is model-first and continuous: from your declarative model, a meta-model will be inferred which code generators will then translate into code. Over 20 code generators (a.k.a. “producers”) are provided “out of the box” and can be combined to create your own application following your desired architecture, using your desired technologies.

Since your application development is driven from this model, your business logic is decoupled from the technology and allows you to absorb changes faster and smoother: apply changes in your model to update all your layers consistently, or add/switch technology by changing your used code generators.

 

So, since everything is driven from this model, what is, technically speaking, a CodeFluent Entities model?

image

Physically, a CodeFluent Entities project is a “package”, that is to say a bunch of files, which we call “parts”. CodeFluent Entities Parts can be of several types:

  1. Model parts: XML or CFP files containing a <cf:project …/> root element,
  2. Surface model parts: XML or CFP files containing a <cf:project …/> root element but reserved to store descriptions of surfaces,
  3. Resource parts: any other file referenced by the <cf:import …/> element, which are not files of type 1 and 2 (yes you can reference images to use them as blobs for instance).

When you load your CodeFluent Entities project in Visual Studio, there are several representations of the model which will coexist:

  1. An in-memory representation (an instance of the Project class and all what’s linked to it),
  2. A graphic representation on one or several opened surfaces,
  3. A XML representation on one or several opened XML files (or CFP).

image

 

What happens when I save?

When you save using Visual Studio’s “Save” menu item, it will save the “current document”, whatever this document may be. So:

  1. Saving using this menu item on an active & opened surface will just save the corresponding “surface model part”. It is equivalent to the  “Save Layout” menu item.
  2. Saving using this menu item on a XML or CFP model part (the active document is then the actual XML file) is completely different. CodeFluent Entities will in fact read the saved model part (XML or CFP), parse it as an independent model, and try to merge it with the current in-memory representation. That’s what is technically called a “part refresh”.

There are then cases when this ”part refresh” can fail:

  • If the file contains XML syntax errors (e.g. missing bracket or tag),
  • If the file is incorrect on a model level (e.g. an entity is already declared in another part or a key is missing)
  • For some other reason!

To troubleshoot this last type of errors, you can use Visual Studio’s “Error List” window  in which CodeFluent Entities will print its errors, including the line number if any.

image

 

Simon Mourier & Carl Anderson

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s