4
I’m starting a project from scratch and in the middle of bank modeling, I had a problem. While building the models, I couldn’t do it the right way and I ended up getting confused.
I have student information, records and logins. Where I have several occurrences for a student and several occurrences for a login, to track which login is generating the occurrence.
But here is my problem: in my table of students I have various information such as student name, father name, mother name, parent name, contact phone, main phone, contact phone and alternative phone.
I thought about putting the parents' names on a different table, as well as the phones, to leave the tables with their respective objections, subjects. That is, organize the affairs. But in doing so, I made several mistakes in doing the scaffolding, because at first it only appeared as dropdown a phone and only the father’s name. Then missing data.
How would I do it? Would I leave all the information on one table? That is, would you delete these phone tables and parents, and leave this information in a single table, that of students? Or not, separating is right, creating these two tables? And how would I?
The models:
Pupil
//Aqui começa a declaração normal dos atributos
public long Id { get; set; }
public string TipoEnsino { get; set; }
public string Nome { get; set; }
public string Endereco { get; set; }
public DateTime DataNascimento { get; set; }
public DateTime AnoLetivo { get; set; }
public int Ano { get; set; }
public string Turma { get; set; }
public int NumeroChamada { get; set; }
public string Foto { get; set; }
public string Observacoes { get; set; }
//Aqui termina
//Aqui começa os relacionamentos
//Ocorrencias
public ICollection<Ocorrencia> Ocorrencias { get; set; }
//Pais
public long PaisId { get; set; }
public Pais Pais { get; set; }
//Telefone
public long TelefoneId { get; set; }
public Telefone Telefone { get; set; }
//Aqui termina
Parents
//Aqui começa a declaração normal dos atributos
public long Id { get; set; }
public string NomePai { get; set; }
public string NomeMae { get; set; }
public string NomeResponsavel { get; set; }
//Aqui termina a declaração
//Aqui começa os relacionamentos
//Aluno
public long AlunoId { get; set; }
public Aluno Aluno { get; set; }
//Aqui termina
Telephone
//Aqui começa a declaração normal de atributos
public long Id { get; set; }
public string Contato { get; set; }
public string Alternativo { get; set; }
public string Responsavel { get; set; }
//Aqui termina a declaração normal
//Aqui começa os relacionamentos
//Aluno
public long AlunoId { get; set; }
public Aluno Aluno { get; set; }
//Aqui termina
It would be interesting to insert the full error message in the question and if possible its model classes and views.
– Renan
So, man, the thing is, I went through the code here and it got messy. But I had relationship mistakes, where Entity didn’t know where it started or ended and then I had Migrations errors, due to the changes I made. But what puzzles me is: How do I mount the student table ? Do you separate this information, like parents' names and phone numbers, into a different table, or do I leave it all on a single table, that is, student’s table ? Because the way I did, I didn’t work. I did the parent tables and the phones and connected 1-1 with the student table. And then it generated me a view with dropdowns. And that’s not what I wanted...
– Érik Thiago
You can ask your Models the question, even if they are messy?
– Leonel Sanches da Silva
@Ciganomorrisonmendez change made ! Sorry for the delay. But these are the models that are giving me a headache.
– Érik Thiago