You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Attachments: Deleting Attachments

Delete from session.Advanced.Attachments is used to remove an attachment from a document.


void Delete(string documentId, string name);
void Delete(object entity, string name);


using (var session = store.OpenSession())
    Album album = session.Load<Album>("albums/1");
    session.Advanced.Attachments.Delete(album, "001.jpg");
    session.Advanced.Attachments.Delete("albums/1", "002.jpg");

using (var asyncSession = store.OpenAsyncSession())
    Album album = await asyncSession.LoadAsync<Album>("albums/1");
    asyncSession.Advanced.Attachments.Delete(album, "001.jpg");
    asyncSession.Advanced.Attachments.Delete("albums/1", "002.jpg");

    await asyncSession.SaveChangesAsync();