I am using the ArcGIS Runtime API for .NET to create a program which can add and remove features from the layers in a FeatureService created with ArcMap 10.5 and deployed to ArcGIS Server 10.5. The feature layers are created from shapefiles where I added additional fields with ArcCatalog 10.5.
The feature layers have 0 features in them when they are deployed.
I create a ServiceFeatureTable for each feature layer and call InitializeAsync(spatialref) and set the OutFields to all fields. I add features by creating a GeodatabaseFeature with the table schema, setting the values for the Attributes, calling ServiceFeatureTable.AddAsync(feature), and then calling ServiceFeatureTable.ApplyEditsAsync(). In some cases UpdateAsync(feature) is called after AddAsync(feature) to adjust certain fields, but the outcome is the same.
The features are added but the values of all the fields (besides the built-in OID and geometry fields) are NULL. The only way to prevent this is to access the geodatabase table through ArcCatalog after deploying the service and then immediately stopping it, and then setting Allow NULLS = No for each field for each feature layer. This workaround is error-prone as it is possible to miss one field, if anybody knows the root cause of this issue help would be greatly appreciated.