-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
關於Migration表名&导航属性 #224
Comments
@ed555009 实在不好意思今天才看到, 1.肯定是不对的不应该生成Transactions sharding-core/samples/Sample.MySql/Startup.cs Line 107 in 1f810f9
|
@ed555009 你要的外键目前没有好办法除了自己执行slq脚本添加 |
您是指我在migration script中自行添加一行constrain foreign key是嗎? |
是的 |
@ed555009 脚本生成出错是因为你没有添加我说的 |
這邊加上 CREATE TABLE "Transactions_2022" (
"Id" bigint GENERATED BY DEFAULT AS IDENTITY,
"MatchId" character varying(15) NOT NULL,
"UserId" bigint NOT NULL,
...
CONSTRAINT "PK_MatchedTransactions_2022" PRIMARY KEY ("Id")
);
想請問,如果是自行在migration script中添加constrain foreign key,那麼未來ShardingCore自動建表
app.ApplicationServices.UseAutoTryCompensateTable();
不好意思,第一次要實作分片,概念上不是很清楚,問題比較多 |
@ed555009 大数据不建议增加外建约束 |
/// <summary>
/// 自动尝试补偿表
/// </summary>
/// <param name="serviceProvider"></param>
/// <param name="parallelCount"></param>
public static void UseAutoTryCompensateTable(this IServiceProvider serviceProvider, int? parallelCount = null)
{
var shardingRuntimeContext = serviceProvider.GetRequiredService<IShardingRuntimeContext>();
shardingRuntimeContext.UseAutoTryCompensateTable(parallelCount);
} 他是 |
是的,Net6將ApplicationServices併入Services了 |
瞭解,那我再想想怎麼驗證Transactions中的UserId,原本是想透過FK來驗證的 |
目前有三個Entities:
User(不分表)
InvoiceSetting(不分表)
Transaction(按年分表)
Transaction virtual table route
Program.cs(WebApi)
Migration script:
Transactions
而不是Transactions_2022
,這樣是正確的嗎?Transaction表
就不支持外鍵約束,請問是否有其他的方式可以做到FK constraint呢?或是其實可以在entity中定義navigation property,只是不要調用Include
就可以呢?謝謝
The text was updated successfully, but these errors were encountered: