如何使用 Entity framework 6 代码优先方法在 SQL 服务器中创建序列并应用两个表?
How to create the sequence and apply two tables in SQL Server using Entity framework 6 code first approach?
我有两个 table A 和 B
Table A - Id 主键不是身份
Table B - Id 主键不是身份 - Id 主键不是身份
如何在 entity framework 6 中创建没有 identity(1,1) 的 A 和 B Table 主键列并为这两个 table.
应用序列
这两个table需要在SQL
中实现顺序
if example Table A insert one record id is 1. and i will insert the Table B id is 2 like this
我被检查身份关闭无法在脚本中工作并且Entity framework 6
也无法在 entity framework 6
中创建序列
但 EFCore 具有顺序功能
modelBuilder.HasSequence<int>("OrderNumbers", schema: "shared")
.StartsAt(1000)
.IncrementsBy(5);
modelBuilder.Entity<A>()
.Property(o => o.Id)
.HasDefaultValueSql("NEXT VALUE FOR shared.OrderNumbers");
在这个
HasSequence not available in Entity Framework 6
如何先在 EF 6 代码中创建序列
有知道的请分享
使用以下过程在上次迁移中添加查询中的序列
public override void Up()
{
Sql("CREATE SEQUENCE tbl_seq START WITH 1 INCREMENT BY 1;");
..........
..........
CreateTable(
"dbo.Table_A",
c => new
{
id = c.Long(nullable: false, identity: false, defaultValueSql:
"NEXT VALUE FOR tbl_seq"),....
}
CreateTable(
"dbo.Table_B",
c => new
{
id = c.Long(nullable: false, identity: false, defaultValueSql:
"NEXT VALUE FOR tbl_seq"),....
}
Set in this place 更改迁移以创建 table of those tables set
身份:假,
defaultValueSql: "NEXT VALUE FOR tbl_seq"
更新数据库后。我们检查那些 table 在那些 table 上应用了序列。
我有两个 table A 和 B
Table A - Id 主键不是身份
Table B - Id 主键不是身份 - Id 主键不是身份
如何在 entity framework 6 中创建没有 identity(1,1) 的 A 和 B Table 主键列并为这两个 table.
应用序列这两个table需要在SQL
中实现顺序if example Table A insert one record id is 1. and i will insert the Table B id is 2 like this
我被检查身份关闭无法在脚本中工作并且Entity framework 6 也无法在 entity framework 6
中创建序列但 EFCore 具有顺序功能
modelBuilder.HasSequence<int>("OrderNumbers", schema: "shared")
.StartsAt(1000)
.IncrementsBy(5);
modelBuilder.Entity<A>()
.Property(o => o.Id)
.HasDefaultValueSql("NEXT VALUE FOR shared.OrderNumbers");
在这个
HasSequence not available in Entity Framework 6
如何先在 EF 6 代码中创建序列
有知道的请分享
使用以下过程在上次迁移中添加查询中的序列
public override void Up()
{
Sql("CREATE SEQUENCE tbl_seq START WITH 1 INCREMENT BY 1;");
..........
..........
CreateTable(
"dbo.Table_A",
c => new
{
id = c.Long(nullable: false, identity: false, defaultValueSql:
"NEXT VALUE FOR tbl_seq"),....
}
CreateTable(
"dbo.Table_B",
c => new
{
id = c.Long(nullable: false, identity: false, defaultValueSql:
"NEXT VALUE FOR tbl_seq"),....
}
Set in this place 更改迁移以创建 table of those tables set
身份:假, defaultValueSql: "NEXT VALUE FOR tbl_seq"
更新数据库后。我们检查那些 table 在那些 table 上应用了序列。