In this case, would it be feasible to record the header, retrieve the last recorded ID for the user and save the Items or would it be better to make a procedure and leave this responsibility with the database?
If you are using Entity Framework, you do not have to do this. You can do this as follows:
var modalidade = db.Modalidades.FirstOrDefault();
var usuario = /* Recupere aqui seu usuário */
var cabecalho = new Cabecalho
{
Modalidade = modalidade,
Usuario = usuario,
ValorJogado = 10,
HoraJogo = DateTime.Now,
Detalhes = new List<Detalhe>
{
new Detalhe { NumeroJogo = 3 }
}
};
db.Cabecalhos.Add(cabecalho);
db.SaveChanges(); // Grava cabecalho e o detalhe automaticamente.
By ADO.NET, you may have to use transactional scope and command two insert operations and a selection between them (bring the header record and set the FK in detail).