Select to view content in your preferred language

What is the suggested offline workflow for storing features from a service in a mobile .NET MAUI application?

482
11
Jump to solution
03-11-2025 08:49 AM
Labels (3)
KevinCheriyan
Frequent Contributor

I have a requirement for my .NET MAUI application that I need to access a feature service from the client's Enterprise Portal and make it available to the user when their device is offline later.

I started with geodatabase as a potential solution, but creating and managing replicas turned out to be a bigger headache for the client than I thought. Otherwise, geodatabases would've been a perfect solution. Is there a way to create a geodatabase with a feature service WITHOUT creating a replica?

I won't use MMPKs, because I just need to take a single layer online. There are also other requirements for the application that prevents us from using MMPKs here.

Is my best option to create a ServiceFeatureTable and then export the features to a custom .sqlite database and then load them into the map page?

Or is this a workflow better done using REST to export features from the service to a .geojson and then somehow load them into the map? 

Thanks for the help! I would be at DevSummit this week asking the Maps SDK team myself, but unfortunately, couldn't make it out there this year. Community ESRI is the next best option!


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

You could roll your own version of sync sure, but the entire replica process is there for this exact scenario to ensure multiple users won't modify the same feature, keep track of what changed, and sync new edits both up and down.

It seems like we cannot use Maps SDK for .NET to query any of this information

This is a REST endpoint. It wouldn't be a lot of work querying and parsing this information. .NET provides lots of great APIs to work with REST and JSON. My guess is that is probably a lot less work than trying to build your own sync framework.

The replica id itself is available on the geodatabase: https://developers.arcgis.com/net/api-reference/api/net/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Data.G...

View solution in original post

11 Replies
MarkBockenhauer
Esri Regular Contributor

Hi Kevin,

Would you be able to use a webmap that is enabled for offline use in your application?If your application involves editing data, this may be a more convenient option.

https://doc.arcgis.com/en/arcgis-online/manage-data/take-maps-offline.htm

 

Mark

KevinCheriyan
Frequent Contributor

Thank you for your response @MarkBockenhauer . 

Assuming all the layers in the client's webmap are approved for offline use...

If we were to take the webmap offline, we'd have to use an on-demand workflow, due to the different map areas that users would need to take offline. But also not sure how scalable this solution is to a large number of users, each of whom would need to take a different area offline. 


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
dotMorten_esri
Esri Notable Contributor

I started with geodatabase as a potential solution, but creating and managing replicas turned out to be a bigger headache for the client than I thought. Otherwise, geodatabases would've been a perfect solution. Is there a way to create a geodatabase with a feature service WITHOUT creating a replica?


Could you elaborate on that a little more on what issues you're encountering? Creating a replica of your geodatabase is the suggested workflow.

KevinCheriyan
Frequent Contributor

We were able to create geodatabase replicas using Feature Service URLs. And these replicas show up on Enterprise in the list of replicas for the service. Great!

But the problem is that the client has some complex workflows around data-sync between different staging environments that requires deleting all replicas and recreating them every few weeks. If the replicas are re-created, there is no way to associate the device-local geodatabase replicas to their replica-pairs in Enterprise. When we check the replica page, we see Replica name, ID, version etc. It seems like we cannot use Maps SDK for .NET to query any of this information. Furthermore, I cannot use the Geodatabase class to get the name or ID of replica in server that was just created. Am I correct? Is there a way to get replica ID using the SDK?

Basically, there seems to be no way to know which device-local geodatabase replica is associated with which replica in the server. 

Thanks! Any insight appreciated!


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
dotMorten_esri
Esri Notable Contributor

Are you not planning to sync any local changes back to the server? If so the preplanned workflow might be better for you.

0 Kudos
KevinCheriyan
Frequent Contributor

We'd like to sync local changes to the service as well, but we were planning on using the SDK's ApplyEdits if the geodatabase replica workflow didn't pan out. 

I think preplanned workflow is out of the question because we don't know which areas of the map users will be performing work in. 

I think the best solution we have right now is a custom implementation of local databases that store attribute and geometry data:

  1. On first app-start, create local .sqlite database with table from FeatureService tables. Probably create a separate field for geometry and a single field to capture all fields-values as key-value pairs. This will give us all the features in the table saved locally. 
  2. On the map page, create features from locally saved data and add as FeatureLayer items with client-side rendering. 
  3. For user to edit this layer data while offline, we save the new attributes and geometry back to the table (or even a new table) and then use ApplyEdits to the service when the device is back online.
  4. On every app-start, I would like to not download all data from scratch everytime, so I'll probably use FeatureRequestMode enum and PopulateFromServiceAsync() method. Needs some looking into on my part

--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
dotMorten_esri
Esri Notable Contributor

You could roll your own version of sync sure, but the entire replica process is there for this exact scenario to ensure multiple users won't modify the same feature, keep track of what changed, and sync new edits both up and down.

It seems like we cannot use Maps SDK for .NET to query any of this information

This is a REST endpoint. It wouldn't be a lot of work querying and parsing this information. .NET provides lots of great APIs to work with REST and JSON. My guess is that is probably a lot less work than trying to build your own sync framework.

The replica id itself is available on the geodatabase: https://developers.arcgis.com/net/api-reference/api/net/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Data.G...

KevinCheriyan
Frequent Contributor

Ok, the syncId property is exactly what I was looking for. Yes, we query REST endpoints elsewhere in the app, so we're fine with those workflows. 

I think I searched for replicaId in the docs, and got zero results. I'll be going with this workflow instead. Thank you for pointing it out! 


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
KevinCheriyan
Frequent Contributor

@dotMorten_esri After discussing with my client, it seems like they want the ability to download pre-created (created from server, not mobile) replicas to the mobile app. Allowing hundreds of field workers to each create replicas is unmanageable when taking into account the bi-weekly data sync workflows I mentioned in my earlier comment. So they want to create replicas server-side and then the mobile app goes and downloads them.

This is more an enterprise question and less a Maps SDK issue at this point, so I'm in the wrong place, but... Is there any way to download replica .geodatabase using REST request? I searched around the replica REST page and I can't find a way to do this. 


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos