我是ASP.NET Core的新手,需要一些指导.我试图找出一个简单的场景,使用ASP.NET Core中的应用程序设置,同时也使用Simple Injector.
我第一次设立了我的强烈型配置设置解释这里由Rick施特拉尔.这非常有效.
public class MySettings
{
public string ApplicationName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
appsetting.json
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"MySettings": {
"ApplicationName": "Test Service"
}
}
Run Code Online (Sandbox Code Playgroud)
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
// Add Options
services.AddOptions();
// Add our Config object so it can be injected
services.Configure<MySettings>(Configuration.GetSection("MySettings"));
services.AddSingleton(GetTestBroker(container));
//Simple Injector
//services.AddSingleton<IControllerActivator>(new SimpleInjectorControllerActivator(container));
//services.AddSingleton<IViewComponentActivator>(new SimpleInjectorViewComponentActivator(container));
}
Run Code Online (Sandbox Code Playgroud)
在我们的其他项目中,正在使用Simple Injector进行DI.添加Simple Injector包并按照说明进行配置后,我看到我的IOptions配置中断了.
我想知道的是,在ASP.NET …
我看过类似的帖子,但我无法找到解决方案来完成这项工作。
我启动一个新应用程序并尝试任何 ef 命令,然后收到此消息。我以前从未在任何版本的 VS 中遇到过这个问题,也没有找到任何真正的解决方案来修复它。
我已经删除了 bin 和 obj 文件夹,更新了 VS,尝试将文件复制到根目录,更新后重新启动了我的机器。
指定的deps.json[]不存在
我在 VS2019 16.10.1 NET Core 5.0
过去有效的 Scaffold-DbContext 现在根本不起作用。
Scaffold-DbContext "Server=servername;User Id=sa;Password=argh;Database=arghdb" Microsoft.EntityFrameworkCore.SqlServer -ContextDir Context -OutputDir Models
Run Code Online (Sandbox Code Playgroud)
不知道现在该怎么办。这太令人沮丧了。
请用 2-3 句话描述问题。包括问题发生时您想要完成的任务。
我正在尝试在 blazor 项目中的 ef core 中搭建数据库。
它何时开始以及发生的频率如何?每次在 blazor 项目中尝试迁移/脚手架时
您看到什么错误?
指定的deps.json [...bin\Debug\net5.0\CourtFilings.Web.deps.json] 不存在
环境如何?最近有什么变化吗?最近没有变化。刚刚更新到VS2019
您尝试过什么来解决此问题?我尝试设置启动项目。我还没有找到其他选择。
这是我尝试的方法,但不起作用
Scaffold-DbContext“服务器=服务器;用户ID=sa;密码=密码;数据库=数据库;” Microsoft.EntityFrameworkCore.SqlServer -ContextDir 上下文 -OutputDir 模型 -Tables CourtFilings -startupproject CourtFilings.Web
这在 ASP.net core Web 项目中确实有效。只是不是 Blazor。这在之前的 Blazor 项目中已经有效。
我正在尝试在 Visual Studio 2019..Net 5.0 中生成 OpenApi 服务引用。
右键单击项目>添加>连接服务>+服务引用
我正在使用 NetDocs api“https://api.vault.netvoyage.com/v2/swagger/docs/v2”。
结果:我生成了 c# 客户端代码,但它复制了类型,并出现以下错误。
Severity Code Description Project File Line Suppression State
Error CS0102 The type 'v2Client' already contains a definition for '_settings' OpenAPITest C:\Users\dryfus\source\repos\OpenAPITest\obj\v2Client.cs 4941 Active
Error CS0579 Duplicate 'System.CodeDom.Compiler.GeneratedCode' attribute OpenAPITest C:\Users\dryfus\source\repos\OpenAPITest\obj\v2Client.cs 4936 Active
Error CS0102 The type 'v2Client' already contains a definition for '_baseUrl' OpenAPITest C:\Users\dryfus\source\repos\OpenAPITest\obj\v2Client.cs 4939 Active
Error CS0102 The type 'v2Client' already contains a definition for '_httpClient' OpenAPITest C:\Users\dryfus\source\repos\OpenAPITest\obj\v2Client.cs 4940 Active
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以让它与连接器方式一起工作而无需重复?甚至是 cli?关于为什么创建重复项有什么建议吗?