Could not find "UserSecretsIdAttribute" in assembly "ef"

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

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

I use the csproj file instead of JSON, where I added:

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

But when I run the command:

 dotnet ef migrations add "InitialCommit" 

I get an error message:

 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" 

Any idea why?

+5
source share
2 answers

You encountered this problem: https://github.com/aspnet/Configuration/issues/543

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

See this announcement on how the depreciation of project.json required breaking user secrets: https://github.com/aspnet/Announcements/issues/209

+7
source

This finally worked for me when I changed the package version in .csproj:

 <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.2" /> 

in

 <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.1" /> 
0
source

Source: https://habr.com/ru/post/1260224/


All Articles