ResourceType Document is unexpected at UpsertDocumentAsync()

asked8 years ago
last updated5 years ago
viewed7.1k times
Up Vote28Down Vote

I'm new to Azure DocumentDB, and I've immediately run into a problem while trying it out. On the first save in an empty collection, I get the following error:

ResourceType Document is unexpected.ActivityId: 29619975-e55a-4f31-a3d1-73d180ba3932 My repository code (partial) is as follows:

public interface IEntity
{
    string Id { get; set; }
    DateTime DbCreatedAt { get; set; }
    DateTime DbLastUpdatedAt { get; set; }
}

public class Repository<T>: IRepository<T> where T: class, IEntity
{
    private DocumentClient _documentClient;
    private string _databaseName;
    private string _collectionName;

    // ....
    // ....

    public Task SaveAsync(T entity)
    {
        var documentUri = UriFactory.CreateDocumentUri(_databaseName, _collectionName, entity.Id);
        return _documentClient.UpsertDocumentAsync(documentUri, entity);
    }
}

This is the first time anything has ever been written to this database/collection. Am I doing something wrong?