SharePoint CSOM : Create Lookup column with additional field

This post shows how to create a lookup column with additional field using SharePoint C# Client side object model code.
I have two lists, Employee List and Department List. The Department List has a Title field and Code field. We will create a lookup column in Employee List which gets information from Title field of Department List. The lookup column will also include the additional Code field. 

List list = clientContext.Web.Lists.GetByTitle("Employee");
List lookupList = clientContext.Web.Lists.GetByTitle("Department");

string lookupFieldSchema = @"<Field Type = 'Lookup' DisplayName = 'Employee Department' 
                    ID = '{769BE2A4-E014-442F-B8F9-5B9581223CF5}' StaticName = 'EmployeeDepartment' 
                    Name = 'EmployeeDepartment' ShowField = 'Title' />";
string additionalFieldSchema = @"<Field Type = 'Lookup' DisplayName = 'Employee Department: Code' 
                            ID = '{A1AE51CF-F273-4E15-9DC1-84B4DC80608E}' 
                            StaticName = 'EmployeeDepartmentCode' Name = 'EmployeeDepartmentCode' 
                            ShowField = 'Code' FieldRef = '769BE2A4-E014-442F-B8F9-5B9581223CF5' />";

Field field = list.Fields.AddFieldAsXml(lookupFieldSchema, true, AddFieldOptions.AddFieldToDefaultView);

Field additionalField = list.Fields.AddFieldAsXml(additionalFieldSchema, true, AddFieldOptions.AddFieldToDefaultView);


The schema for both fields has a List property which contains the List ID of the Department List. The ShowField attribute of the lookup column gets value from Title field of the Department List and the ShowField attribute of the additional field gets its value from Code filed of the Department List. The other important property of additional field is the FieldRef property which contains the ID of the lookup column.
Lookup Column