mysql - how to design mvc entity models -


its pain me design models. way iam progressing is:

  1. find out data involved
  2. create database data
  3. 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:

  1. employeerating : id | employee_id | tag_id | rating
  2. 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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -