While Karen's answer is correct, I do want to point out that Entity Framework will automatically hydrate your models with identity fields when you insert. So for example if I have :
class Customer
{
public int Id { get; set; }
public string Name { get; set; }
}
class CustomerService
{
int MyMethod()
{
var customer = new Customer { Name = "Abc" };
_customerRepository.Add(customer);
return customer.Id; //Notice how we never touched this field, but after our insert, EF will populate it for us.
}
}
Notice how we don't add or modify the Id field, but after our insert, we can return it fine. While this may not work perfectly in your scenario, I just wanted to show that your add method may not need to return the identity at all, as if you have a reference to the original object, the ID will be set within it.