Generating Schemas - Ackara/Daterpillar GitHub Wiki

Let say you have the following class.

[Table]
public class Employee
{
	[Column(AutoIncrement = true)]
	pulbic int Id { get; set; }
	
	[Column]
	public string Name { get; set; }
}

Granted you have installed the package using NuGet, a MSBuild target will be included so when you build your project a *.schema.xml file will be generated along side your project's .dll file in the bin directory. The file will look something like the following.

<schema xmlns="http://static.acklann.com/schema/v2/daterpillar.xsd">
  <table name="employee">
	<column name="Id" autoIncrement="true">
	  <dataType>int</dataType>
	</column>

	<column name="Name">
	  <dataType scale="64">varchar</dataType>
	</column>
  </table>
</schema>

What you can then do with the file is generate a MySQL script using the powershell module that comes with the package. You can also install from the powerhshell gallery.

PS> Install-Module -Name Daterpillar.Automation

Once imported can use the following to generate a MySQL script.

you will get MySQL

CREATE TABLE employee
(
	Id INT PRIMARY KEY AUTO_INCREMENT,
	Name VARCHAR(64)
);

in C#

public class Employee
{
	public int Id { get; set; }
	public int Name { get; set; }
}

Creating your own template or customizing an existing one is also easy.

⚠️ **GitHub.com Fallback** ⚠️