I am running the Firestore emulator as a Docker container and facing two issues. Here's the code I'm using:
Environment.SetEnvironmentVariable("FIRESTORE_EMULATOR_HOST", "localhost:8080");
var builder = new FirestoreDbBuilder
{
ProjectId = "default",
EmulatorDetection = EmulatorDetection.EmulatorOrProduction
};
var firestoreDb = builder.Build();
var col = firestoreDb.Collection("Cities");
var docRef = col.Document("YVR");
var result = await docRef.SetAsync(new City { Name = "Vancouver", Population = 675_000 });
var doc = await docRef.GetSnapshotAsync();
doc.Exists.Dump();
var document = firestoreDb.Collection("Cities").Document("YVR");
var snapshot = await document.GetSnapshotAsync();
snapshot.Exists.Dump();
var city = snapshot.ConvertTo<City>();
city.Dump();
City is defined as:
[FirestoreData]
public class City
{
[FirestoreDocumentId]
public string Id { get; set; }
[FirestoreProperty]
public string Name { get; set; } = null!;
[FirestoreProperty]
public int Population { get; set; }
}
Question 1
Without specifying ProjectId, I get an exception ArgumentNullException,
Value cannot be null. (Parameter 'projectId'). Shouldn't a null value resolve to the emulator since the FIRESTORE_EMULATOR_HOST environment variable is provided?

And what project ID value should it be if working with the emulator?
Question 2
If I put a value for ProjectId, the code works, but using the emulator UI at the default URL http://127.0.0.1:4000/firestore/data doesn't show the document I'm adding.
c#and thread2gcloud emulators firestore startbut that doesn't have a UI, so presumably you're using the one documented at firebase.google.com/docs/emulator-suite?)