I am using ArcGIS Pro SDK for .NET version 126.96.36.19913.
Based on community sample ChangeLayerDataSource.cs I have implemented Data Source change functionality using SetDataConnection method.
Everything works fine except the cases when WorkspaceFactory changes from FileGDB to SDE or the other way around, from SDE to FileGDB. After setting the new Data Connection, the new parameters are attached to the featureLayer, but when reading the layers again with MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>(), the featureLayer.GetFeatureClass() shows the old FeatureClass. After closing/saving and reopening the project the FeatureClass is updated and SDK shows it correctly with featureLayer.GetFeatureClass().
Has anyone had a similar issue and is there a way to refresh FeatureClass programmatically to be used in SDK?
Thanks in advance,