使用EF 6.1+时,我们需要添加或删除现有的conentions.代码看起来或多或少像:
public class MyContext : DbContext
{
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.AddFromAssembly(Assembly.GetExecutingAssembly());
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>();
base.OnModelCreating(modelBuilder);
}
}
Run Code Online (Sandbox Code Playgroud)
如何在EF核心中做到这一点?Modelbuilder没有会议特性:(
最近我配置了Serilog以与ASP.NET Core 2 MVC应用程序配合使用,接下来的任务是在系统的每一层上跟踪传入的Web应用程序请求.所以基本上,我们想要传播一些令牌(比如RequestId由Serilog生成到较低层的应用程序).
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.RollingFile" ],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Warning"
}
},
"WriteTo": [
{
"Name": "RollingFile",
"Args": {
"pathFormat": "log-{Hour}.txt",
"fileSizeLimitBytes": "",
"retainedFileCountLimit": "",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Application}] [{Level}] [{RequestId}] - {Message}{NewLine}{Exception}"
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Properties": {
"Application": "MultilayerApp"
}
},
Run Code Online (Sandbox Code Playgroud)
在日志中,我们有很好的输入
2018-01-19 14:06:01.165 +00:00 [App] [Warning] [0HLAV6PIMA9M0:00000001] - Accessing expired session, Key:"6e7f3ab5-db62-335d-1bc7-6824e5b918f5"
Run Code Online (Sandbox Code Playgroud)
但我的问题是Serilog在哪里实现更丰富RequestId?老实说,我找不到它.
众所周知,rabbitMQ 之类的消息总线主要用于异步消息传递,因此标准方法是触发并忘记在总线上发布某些内容,而不必担心谁将处理已发布的消息或何时处理。但我正在考虑我们开发团队中关于消息同步处理的最新讨论:案例是将消息发布到服务总线,作为发布者,我想等待任何订阅者处理消息并将结果返回给我 - 所以它看起来而是作为请求-响应模型。我现在在想一个缺点,比如在这个模型中降低性能。你怎么看?何时使用异步,何时使用同步?有哪些权衡?
我们在生产环境中使用 Pomelo MySql 半年了,它运行得很好,但偶尔我们会遇到如下异常:
MySql.Data.MySqlClient.MySqlException: The Command Timeout expired before the operation completed.
Run Code Online (Sandbox Code Playgroud)
appsettings.json 中的连接字符串如下所示:
"MySqlConnection": "服务器=somesql;用户id=用户;密码=pass;数据库=测试;"
所以没什么特别的。
我的问题是 pomelo 中默认的命令执行超时是多少?如何通过连接字符串更改它?
在 DbContext 中执行这样的代码
var timeout = Database.GetCommandTimeout();
Run Code Online (Sandbox Code Playgroud)
总是给我空值。
目前我在升级的ASP网核心2.2的网站使用Identity Server的4验证和发现的问题是阻止我完成这个任务网的核心3.0:在.NET 3.0的核心是没有AddOpenIdConnect的方法OpenIdConnectExtensions(文档是明确它:
那么.net core 3.0 有什么替代品吗?
在 net core 2.2 中工作的 Startup.cs
IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie(options =>
{
options.SlidingExpiration = true;
options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
})
.AddOpenIdConnect("oidc", options =>
{
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.Authority = "sso url";
options.RequireHttpsMetadata = false;
options.ClientId = "client_id";
options.ClientSecret = "secret";
options.ResponseType = $"{OpenIdConnectParameterNames.Code} {OpenIdConnectParameterNames.IdToken}";
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
})
Run Code Online (Sandbox Code Playgroud) asp.net-core ×2
c# ×2
asynchronous ×1
logging ×1
messaging ×1
mysql ×1
pomelo-entityframeworkcore-mysql ×1
rabbitmq ×1
serilog ×1
synchronous ×1