Skip to content

Commit

Permalink
(#215) Docs for MySQL (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianhall authored Jan 22, 2025
1 parent b7b68ff commit 1863c4a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/content/in-depth/server/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Default repository implementations are provided for Entity Framework Core, LiteD
* [Azure SQL and SQL Server](./databases/azuresql.md)
* [In Memory Datastore](./databases/in-memory.md)
* [LiteDb](./databases/litedb.md)
* [MySQL](./databases/mysql.md)
* [PostgreSQL](./databases/postgresql.md)
* [Sqlite](./databases/sqlite.md)

Expand Down
1 change: 1 addition & 0 deletions docs/content/in-depth/server/databases/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ For specific database support, see the following:
* [Azure SQL and SQL Server](./azuresql.md)
* [In Memory Datastore](./in-memory.md)
* [LiteDb](./litedb.md)
* [MySQL](./mysql.md)
* [PostgreSQL](./postgresql.md)
* [Sqlite](./sqlite.md)
27 changes: 27 additions & 0 deletions docs/content/in-depth/server/databases/mysql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
+++
title = "MySQL"
+++

## MySQL

Add the [`Pomelo.EntityFrameworkCore.Mysql`](https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql) driver to your project.

> [!INFO]
> You can probably use the `MySql.EntityFrameworkCore` library as well. However, we only test with the Pomelo driver.
In the `OnModelCreating()` method of your context, add the following for each entity:

```csharp
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Model>().Property(m => m.UpdatedAt)
.ValueGeneratedOnAddOrUpdate();

modelBuilder.Entity<Model>().Property(m => m.Version)
.IsRowVersion();

base.OnModelCreating(modelBuilder);
}
```

* [Test MySQL Context](https://github.com/CommunityToolkit/Datasync/blob/main/tests/CommunityToolkit.Datasync.TestCommon/Databases/MySQL/MysqlDbContext.cs)

0 comments on commit 1863c4a

Please sign in to comment.