在程序集"ef"上找不到"UserSecretsIdAttribute" [英] Could not find 'UserSecretsIdAttribute' on assembly 'ef'

查看:90
本文介绍了在程序集"ef"上找不到"UserSecretsIdAttribute"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASP.NET Core 1.1,并且在启动时具有以下内容:

I am using ASP.NET Core 1.1 and I have the following on startup:

ConfigurationBuilder builder = new ConfigurationBuilder();
builder.AddUserSecrets();

我使用的是csproj文件而不是我添加的JSON:

I am using csproj file instead of JSON where I added:

<PropertyGroup>
   <UserSecretsId>8844d677-223b-4527-a648-387a65933d55</UserSecretsId>
</PropertyGroup>

但是当我运行命令时:

dotnet ef migrations add "InitialCommit"

我得到了错误:

An error occurred while calling method 'ConfigureServices' on startup class 'Startup'. Consider using IDbContextFactory to override the initialization of the DbContext at design-time. Could not find 'UserSecretsIdAttribute' on assembly 'ef, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60"

知道为什么吗?

推荐答案

您遇到了这个问题: https://github.com/aspnet/Configuration/issues/543

解决方案是将您的调用 .AddUserSecrets()更改为 .AddUserSecrets(Assembly assembly)

The solution is to change your call .AddUserSecrets() to .AddUserSecrets(Assembly assembly)

请参阅此公告,以了解弃用project.json如何要求对用户机密进行重大更改: https://github.com/aspnet/Announcements/issues/209

See this announcement about how deprecating project.json required a breaking change to user secrets: https://github.com/aspnet/Announcements/issues/209

这篇关于在程序集"ef"上找不到"UserSecretsIdAttribute"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆