Using SingleStore with Entity Framework
Download full source code.
Here is the next in my series of posts showing how to use various databases with Entity Framework Core.
This time it’s the turn of SingleStore, a distributed SQL database that is designed for high performance and scalability.
SingleStore is compatible with MySQL, so you can use the MySQL library for Entity Framework to connect to it.
Docker
First, get SingleStore running in a Docker container. This will start two nodes - a Master Aggregator and a leaf. It will also expose the necessary ports for you to connect to it.
docker run -d --name singlestoredb-dev -e ROOT_PASSWORD="my-secret-pw" -p 3306:3306 -p 8080:8080 -p 9000:9000 ghcr.io/singlestore-labs/singlestoredb-dev:latest
- 3306 is the standard MySQL port
- 8080 is the SingleStore web interface
- 9000 is a JSON over HTTP protocol
The Application
The application is a simple console application that uses Entity Framework to connect to SingleStore, create a database, seed it, and perform a simple select statement. The full source code is in the attached zip file.
There is not a lot to it so I leave it the to reader to download the file and try it out.
The Web Interface
You can access the SingleStore web interface at http://localhost:8080. You can log in with the username root
and the password you set in the Docker command above.
From there you can see the hosts, nodes, databases, tables, and run SQL queries.
Download full source code.