Not sure what you want exactly since you did not post your author creation. But see if this helps
Author author =context.Authors.SingleOrDefault(o=>o.AuthorId ==authorId);
if(author ==null)
{
author = new Author ();
//set properties
context.Authors.Add(author);
}
Document d=new Document();
d.Authors.Add(a);