title: How to add a node with child properties and set values to them?
body: <p>I have built a OPC UA server from the  OPCFoundation example - <a href="https://github.com/OPCFoundation/UA-.NETStandard" rel="nofollow noreferrer">https://github.com/OPCFoundation/UA-.NETStandard</a></p>
  
  <p>Also compiled my own model with - 
  <a href="https://github.com/Pro/UA-ModelCompiler/tree/eebf9988940a789a4f36cbef8c5bd6340f1b2f42" rel="nofollow noreferrer">https://github.com/Pro/UA-ModelCompiler/tree/eebf9988940a789a4f36cbef8c5bd6340f1b2f42</a> </p>
  
  <p>In the examples they have the generated files in folders and then custom made classes for NodeManger, State and so on.</p>
  
  <p>I have successfully loaded the generated .uanodes file, with some example nodes in it. But I cannot create those nodes by code from server side. When testing I am doing it in the function - LoadPredefinedNodes(ISystemContext context).</p>
  
  <p>My structure should be a node below Objects called "Tags", in that node I want to dynamically add nodes and set their properties when the server is running.</p>
  
  <p>I am using Integration Object´s OPC UA Client when testing.</p>
  
  <p>The strucure looks correct, for example:
  Objects => Tags => MyTestTag (Properties: Name, Description, Value)</p>
  
  <p>The first two properties are added correctly from the model file definition</p>
  
  <pre class="lang-xml prettyprint-override"><code>    &lt;!-- ### Object Types ###--&gt;
  
      &lt;!-- BaseType --&gt;
      &lt;ObjectType SymbolicName="TAG:TagType" BaseType="ua:BaseObjectType" IsAbstract="true" SupportsEvents="true" AccessLevel="ReadWrite"&gt;
          &lt;Description&gt;Base type for all tags&lt;/Description&gt;
          &lt;Children&gt;
              &lt;Property SymbolicName="TAG:Name" DataType="ua:String" ValueRank="Scalar" ModellingRule="Mandatory" AccessLevel="ReadWrite"&gt;
                  &lt;Description&gt;Name of the tag&lt;/Description&gt;
              &lt;/Property&gt;
              &lt;Property SymbolicName="TAG:Description" DataType="ua:String" ValueRank="Scalar" ModellingRule="Optional" AccessLevel="ReadWrite"&gt;
                  &lt;Description&gt;Description of the tag&lt;/Description&gt;
              &lt;/Property&gt;
          &lt;/Children&gt;
      &lt;/ObjectType&gt;
  
      &lt;!-- ### Objects ###--&gt;
      &lt;Object SymbolicName="TAG:Tags" TypeDefinition="ua:BaseObjectType"&gt;
          &lt;Description&gt;Contains all instances of tags&lt;/Description&gt;
          &lt;References&gt;
              &lt;Reference IsInverse="true"&gt;
                  &lt;ReferenceType&gt;ua:Organizes&lt;/ReferenceType&gt;
                  &lt;TargetId&gt;ua:ObjectsFolder&lt;/TargetId&gt;
              &lt;/Reference&gt;
          &lt;/References&gt;
      &lt;/Object&gt;
  </code></pre>
  
  <p>The third is the Property I try to define from code on server side. I got the Value property added, but I cannot figure out how to write it´s value.</p>
  
  <pre class="lang-cs prettyprint-override"><code>        protected override NodeStateCollection LoadPredefinedNodes(ISystemContext context)
          {
              NodeStateCollection predefinedNodes = new NodeStateCollection();
              predefinedNodes.LoadFromBinaryResource(context, "Opc.Ua.ValmetData.Tag.Tag.PredefinedNodes.uanodes", this.GetType().GetTypeInfo().Assembly, true);
  
              // The defined ObjectType in the model
              NodeState tageTypeNode = predefinedNodes.Find(x =&gt; x.SymbolicName == "TagType");
  
              // List node to add the tag to
              NodeState tagsNode = predefinedNodes.Find(x =&gt; x.SymbolicName == "Tags");
  
              ushort namespaceIndex = Server.NamespaceUris.GetIndexOrAppend(Namespaces.Tag);
  
  
              TagState tagNode = new TagState(tagsNode);
              tagNode.SymbolicName = "MyTestTag";
              tagNode.ClearChangeMasks(context, true);            
  
              PropertyState ps = new PropertyState(tagNode);
              ps.ClearChangeMasks(context, true);
              ps.NodeId = new NodeId();
              ps.Description = "This is a description";
              ps.TypeDefinitionId = tageTypeNode.NodeId;
              ps.NumericId = 66;
              //  ps.NodeClass = NodeClass.Variable;
              ps.ReferenceTypeId = ReferenceTypeIds.HasProperty;
              ps.BrowseName = new QualifiedName("Value", NamespaceIndex);
              ps.DisplayName = ps.BrowseName.Name;
              ps.DataType = (uint)BuiltInType.Int32;
              // ps.UserAccessLevel = AccessLevels.CurrentReadOrWrite;
              // ps.AccessLevel = AccessLevels.CurrentReadOrWrite;
              ps.Value = 66;
  
              tagNode.AddChild(ps);
  
              // assign
              tagNode.Create(
                  SystemContext,
                  new NodeId(tagNode.SymbolicName, namespaceIndex),
                  new QualifiedName(tagNode.SymbolicName, namespaceIndex),
                  null,
                  true);
  
              tagsNode.AddChild(tagNode);
  
              return predefinedNodes;
  
  }
  
  </code></pre>
  
  <p>From this code a node named MyTestTag is added in the Tags node. Properties "Name" and "Description" is added from the model. And the "Value" property is added by code. However, I cannot set the value for non of those properties.</p>
  
  <p>When clicking on the property MyTestTag.Value in the client the error "Nullable object must have a value" is printed.</p>
  
  <p>Please tell me what I am doing wrong.</p>