Can I generate table schema from a model class?

Viewed 29

As database I use MySql. I want to generate table schema of a model class? Is this possible?

For example I have a class named Courses that look like this:

public class Courses 
    {
        public virtual int Id { get; set; }
        public virtual string Name { get; set; }
        public virtual IList<Students> AttendeesStudents { get; set; }
    }

Having this information I want to create the table schema that will look something like this

CREATE TABLE courses (
  Id varchar(40) NOT NULL,
  Name varchar(40) NOT NULL,
  PRIMARY KEY (Id),
  KEY IX_UNIQUE_UPDATE (Name)
) ENGINE=InnoDB;
0 Answers
Related