Connection
To access micron, you need to import Micron namespace.
Add Configuration
MariaDB (formerly known as MySQL) is the most popular database among web and app developers. Use MariaDB or MySQL for light web development.
To connect to a MySQL database or a MariaDB database:
You can also setup multiple connections:
It is recommended to add connection code at the main function of your app before you load other modules.
Creating a connection.
To create a connection you just create an instance of MicronDBContext
This will create a connection using the default connection configuration (which is the first connection added)
To create a connection to a specific connection config. Just add the configuration name as parameter
Direct connection
You can create a micron connection by passing all the connection options as parameters.
This method is not recommended since the model generator relies on MicronConfig instance to create a connection. But once you have models already generated, you can use this connection in production.
Last updated