我们需要支持这两个数据库:SQL Server和PostgreSQL.对于乐观并发,我们使用[Timestamp]
列.
对于SQL Server,此代码可以工作:
public class DbEntity
{
...
[Timestamp]
public byte[] Timestamp { get; set; }
...
}
在数据库中,此字段映射到:
[Timestamp] [timestamp] NOT NULL
对于PostgreSQL,我们需要如下内容:
public class DbEntity
{
...
[Timestamp]
public uint Version { get; set; }
...
}
数据库中没有列,因为xmin系统列使用了-https://www.npgsql.org/efcore/modeling/concurrency.html?tabs=data-annotations
是否有可能编写同时使用这两个数据库的通用实体?我想写一次,不支持2个应用程序或2个分支的源代码控制.