code_junkie

Generate Database from NHibernate config files

Nov 13th, 2011
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. var cfg = new NHibernate.Cfg.Configuration();
  2. cfg.SetProperty("hbm2ddl.auto", "create");
  3. cfg.Configure();
  4.  
  5. <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  6. <session-factory>
  7. <property name="hbm2ddl.auto">create</property>
  8.  
  9. <?xml version="1.0" encoding="UTF-8"?>
  10.  
  11. <hibernate-mapping
  12. xmlns="urn:nhibernate-mapping-2.0"
  13. default-cascade="none">
  14.  
  15. <class
  16. name="Your.Domain.AddressImpl, Your.Domain"
  17. table="[ADDRESS]"
  18. dynamic-insert="true"
  19. dynamic-update="true"
  20. lazy="true">
  21.  
  22. <id name="Id" type="long" unsaved-value="0">
  23. <column name="ID" sql-type="NUMERIC(19,0)"/>
  24. <generator class="native"> </generator>
  25. </id>
  26.  
  27.  
  28.  
  29. <property name="Address1" type="string">
  30. <column name="ADDRESS1" not-null="true" unique="false" sql-type="VARCHAR(100)"/>
  31. </property>
  32.  
  33. <property name="Address2" type="string">
  34. <column name="ADDRESS2" not-null="true" unique="false" sql-type="VARCHAR(100)"/>
  35. </property>
  36.  
  37. <property name="City" type="string">
  38. <column name="CITY" not-null="true" unique="false" sql-type="VARCHAR(100)"/>
  39. </property>
  40.  
  41. <property name="State" type="string">
  42. <column name="STATE" not-null="true" unique="false" sql-type="VARCHAR(100)"/>
  43. </property>
  44.  
  45. <property name="Zipcode" type="string">
  46. <column name="ZIPCODE" not-null="true" unique="false" sql-type="VARCHAR(100)"/>
  47. </property>
  48.  
  49.  
  50.  
  51.  
  52. </class>
  53. </hibernate-mapping>
  54.  
  55. using System;
  56.  
  57. namespace Your.Domain
  58. {
  59.  
  60. public partial class Address
  61. {
  62.  
  63.  
  64.  
  65. #region Attributes and Associations
  66.  
  67. private string _address1;
  68. private string _address2;
  69. private string _city;
  70. private long _id;
  71. private string _state;
  72. private string _zipcode;
  73.  
  74. #endregion
  75.  
  76. #region Properties
  77.  
  78. /// <summary>
  79. ///
  80. /// </summary>
  81. public virtual string Address1
  82. {
  83. get { return _address1; }
  84. set { this._address1 = value; }
  85. }
  86.  
  87. /// <summary>
  88. ///
  89. /// </summary>
  90. public virtual string Address2
  91. {
  92. get { return _address2; }
  93. set { this._address2 = value; }
  94. }
  95.  
  96. /// <summary>
  97. ///
  98. /// </summary>
  99. public virtual string City
  100. {
  101. get { return _city; }
  102. set { this._city = value; }
  103. }
  104.  
  105. /// <summary>
  106. ///
  107. /// </summary>
  108. public virtual long Id
  109. {
  110. get { return _id; }
  111. set { this._id = value; }
  112. }
  113.  
  114. /// <summary>
  115. ///
  116. /// </summary>
  117. public virtual string State
  118. {
  119. get { return _state; }
  120. set { this._state = value; }
  121. }
  122.  
  123. /// <summary>
  124. ///
  125. /// </summary>
  126. public virtual string Zipcode
  127. {
  128. get { return _zipcode; }
  129. set { this._zipcode = value; }
  130. }
  131.  
  132.  
  133. #endregion
  134. }
  135. }
Add Comment
Please, Sign In to add comment