mysql - how to design mvc entity models -
its pain me design models. way iam progressing is:
- find out data involved
- create database data
- create entity models data manually ie without table2class conversion
the reason told without table2class conversion is: need understand how on mysql/manually. beginner , feel hard each time put hand on area.
consider example of saving rating employee , company. employee can rate self , several employees can rate company. database become:
- employeerating : id | employee_id | tag_id | rating
- companyrating : id | company_id | employee_id | tag_id | rating
how design models scenario. don't it. below model wanted.
[table("employee")] public class employee { [key] public int id { get; set; } ... public list<rating> ratings { get; set; } } [table("company")] public class company { [key] public int id { get; set; } ... list of list of rating can seperate each employee should come here }
how design models accomplish employee_rating , employee_company_rating. please point if iam entirely wrong.
also suggest tutorial me on how do/think model design
that's data-centric approach , there plenty of resources out there that. might want consider more object oriented approach code first encourages. https://softwareengineering.stackexchange.com/questions/264379/code-first-vs-database-first
as current issue, based on describe want class bridges employees , companies:
public class companyemployee { public int companyid { get; set; } public int employeeid { get; set; } ... public list<rating> companyratings { get; set; } }
you can add list of employees company navigation. also, don't need table annotations if class , table name same.
Comments
Post a Comment