How to name the foreign key in the Entity framework

4
public class Lancamento {

     // Colunas e métodos omitidos 

     [Column("IdContaBancaria")]
     public virtual ContaBancaria ContaBancaria { get; set; }
}

public class ContaBancaria
{
        [Key] // PK
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)] // Será auto incremento
        [Column("idContaBancaria"]
        public int IdContaBancaria { get; set; }   

        public virtual ICollection<Lancamento> LancamentosCB { get; set; }
       // Colunas e métodos omitidos 
}

I would like to make explicit the name of fk but the name always generated [ContaBancaria_IdContaBancaria]

How to set the foreign key name?

    
asked by anonymous 23.02.2015 / 16:46

1 answer

2

Using the ForeignKey attribute:

[ForeignKey("fk_nome")]
    
23.02.2015 / 16:57