So you have started using DevExpress XPO/XAF and now you would like to see how to use the EDMX (Entity Data Model XML) visual designer within Visual Studio to draw your entities and relationships. First let’s explain the steps we are going to do and what is taking place, then I’ll give you the steps to accomplish this.
The EDMX design surface is what is currently being used to generate Entity Framework code. What we have done is to intercept the saving of the diagram and use this to generate XPO/XAF code according to DevExpress syntax. Why? So that we can more quickly visualize and see our entity model. My goal was to create a tool that I could sit down with my end users in a planning session and crank out a prototype. If anyone has users you know that they know what they don’t want as soon as they see it. Let’s cut that cycle down so that we can more get better software out faster.
Step 1. Download and install the EDMX Visual Studio Extension for XAF/XPO.
The extension can be found http://efxaf.codeplex.com. Just download it and install the Liekhus.EntityFramework.XAFExtensions.vsix file. This is the Visual Studio Extension file. You can then ensure that it is installed by looking at your installed extensions by going to Tools –> Extension Manager. You should see something like this below screen shot.

The code generator is now installed. Let’s move to the next step.
Step 2. Create your XAF project (if necessary)
If you are creating a new project then use the standard XAF Solution project to create a new project. There are no special tips or tricks here.
If you are using an existing project then you are set and ready to go.
Step 3. Add an EDMX (Entity Data Model) to your Module project
Add a “New Item” to your Module project. Select ADO.NET Entity Data Model under the Data section as shown below.

The name of the file does not matter. Once you start creating your model, the name of the entities will drive the name of the code generated files. Select the Empty Model option from the next screen.

Click the Finish button and the designer surface will be created.
Step 4. Turn off the Entity Framework default code generation.
This is the most important step. You must turn off the default action of the EDMX file. Right click on the designer surface and view the Properties. Set the Code Generation Strategy to None. This is what causes the model to create the Entity Framework classes. By installing the Visual Studio Extension in the above steps, when the model is saved you will now generate XPO/XAF classes based on DevExpress standards.

Step 5. Create your model.
You can either use the toolbox, drag tables from the data explorer or use the wizards to create your model. This step is using the standard EDMX designer to model the entities and their relationships. There is no trickery here. Below is an example model that I have built using the tool.

One thing to note is that we have built several of the XPO/XAF properties into the designer. The properties below are visible when you click on an Entity.

You can see these properties when clicking on a property.

As you can see, you can set most of the properties just by entering simple property values. In the above example, simply by putting in the display message in the Rule Required Message the XAF toolset will require the field to be completed and will also throw the above message when needed.
You will also notice all key fields have been removed from the model. This is because all entities will be generated from the base object DevExpress.Persistent.BaseImpl.BaseObject. This provides the Oid key based upon the XPO design. You can change the base object, this is strictly a default and the recommended approach.
Step 6. Save your model.
Simply save your model. You should see several things take place here.
For each of your entities, a concrete and generated source file will be created as partial classes. For example, the Album class above will look like this below

The concrete class is where you should put your custom code (if needed) for things such as OnSave or BeforeSave logic. This will depend on your implementation and/or solution for your needs. By default it should look something like this. This file will only be created the first time. Once it is saved, your code will not be altered from this point forward.

The generated class is following the Windows form designer pattern by including the code generated file directly below the concrete class. DO NOT (I repeat DO NOT) make changes to this code in the designer class. Each time you save your EDMX file, this file will be overwritten.

What you will see here is that the attributes to support XPO/XAF are generated based upon the properties that were set on the model. Try exploring with different settings and see how they react in the application.
Step 7. Build your application according to XAF standards and best practices.
Set any additional properties and attributes on the XAF Model. You can run your application and see your entities in action.
That’s it for this tutorial. What we have done is to use the designer surface of the ADO.NET Entity Data Model and intercept the save to code generate XPO/XAF classes. Once that is done DevExpress has done a tremendous job on their framework and we let them take over from there.
If you have any questions/comments/concerns, please feel free to post them below. And remember, stay tuned as there are more tools and tricks to come.