· 8 years ago · Jun 18, 2018, 10:14 PM
1Configuration configuration = new Configuration();
2configuration.Configure();
3SchemaExport schemaExport = new SchemaExport(configuration);
4using(TextWriter stringWriter = new StreamWriter("create.sql"))
5{
6 schemaExport.Execute(false, false, false, true, null, stringWriter);
7}
8
9<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
10<session-factory>
11 <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
12 <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
13 <property name="connection.connection_string">Server=localhost;Database=db;User ID=root;Password=sa;</property>
14 <property name="dialect">NHibernate.Dialect.MySQLDialect</property>
15</session-factory>
16
17alter table Order drop foreign key FK_User_Order
18alter table OrderItem drop foreign key FK_Order_Item
19alter table Item drop foreign key FK742DC178AD99756A
20
21drop table if exists User
22drop table if exists Order
23drop table if exists OrderItem
24drop table if exists Item
25drop table if exists Category
26create table User (
27 Id INTEGER NOT NULL AUTO_INCREMENT,
28 role INTEGER not null,
29 is_active TINYINT(1) not null,
30 contact_name VARCHAR(100),
31 phone VARCHAR(100),
32 address VARCHAR(100),
33 email VARCHAR(100) not null,
34 name VARCHAR(100) not null,
35 password_hash LONGBLOB not null,
36 login VARCHAR(100) not null unique,
37 is_new TINYINT(1) not null,
38 price_type INTEGER not null,
39 access_id INTEGER not null,
40 primary key (Id)