As far as I could understand, you did the same schema in your question and migration
generated the field names by their default form ( migration has its default form, if do not put the settings the code generates the names including the relations of their way ), this happens for lack of initial configuration, the important thing is always to do the right thing, and put the relationships as you wish, names and ways not to have these problems, although in your case it is not a problem just do what you need so that it creates a new% update migration
to solve the problem.
Changes must be made to the classes and re-run Migration
[Table("Editora")]
public class Editora
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int EditoraID { get; set; }
public string Nome { get; set; }
public virtual List<Livro> Livros { get; set; }
public virtual List<Telefone> Telefones { get; set; }
}
[Table("Telefone")]
public class Telefone
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int TelefoneID { get; set; }
public string Fixo { get; set; }
public string Cel { get; set; }
public int EditoraID { get; set; }
[ForeignKey("EditoraID")]
public virtual Editora Editora { get; set; }
}
[Table("Livro")]
public class Livro
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int LivroID { get; set; }
public string Titulo { get; set; }
public int EditoraID { get; set; }
[ForeignKey("EditoraID")]
public virtual Editora Editora { get; set; }
}
Ready with this the configurations can be updated and with an ideal nomenclature, like:
Retype the commands:
add-migration update3
and then
update-database
Tip: Any changes to your classes that will generate new settings on your base will repeat the commands Fluent API
and then add-migration
as new settings or changes will be applied.