![](/img/trans.png)
[英]Entity Framework Core and EF6 - dotnet ef migrations add InitialCreate - Value cannot be null. (Parameter 'connectionString')
[英]Currently trying to learn Microsoft.net core, but it is giving this error Value cannot be null. (Parameter 'connectionString')
这是我的 appsettings.json:
{
"ConnnectionStrings": {
"DefaultConnection":"Data Source=DatingApp.db "
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
和启动类:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<DataContext>(x => x.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));
services.AddControllers();
}
我正在尝试“dotnet ef 数据库更新”,但它仍然给我这个错误我搜索了问题并尝试了所有解决方案。 如果有人可以帮助我,那就太好了!
确保基于环境的设置文件中没有空连接字符串。
默认情况下 asp.net 核心工程模板创建多个设置文件appsettings.json
和appsettings.Development.json
基于当前ASPNETCORE_ENVIRONMENT
.
您还可以检查系统中当前的ASPNETCORE_ENVIRONMENT
值。 运行echo %ASPNETCORE_ENVIRONMENT%
因此,您在错误文件中添加了连接字符串或在基于 env 的设置中有空的可能错误之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.