Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find 'UserSecretsIdAttribute' on assembly 'ef'

Tags:

asp.net-core

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

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

I am using 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 the error:

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?

like image 993
Miguel Moura Avatar asked Nov 23 '16 16:11

Miguel Moura


2 Answers

You have run into this issue: https://github.com/aspnet/Configuration/issues/543

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

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

like image 99
natemcmaster Avatar answered Nov 10 '22 08:11

natemcmaster


I had this issue also. My solution was to install the nuget package Microsoft.Extensions.Configuration.UserSecrets.

like image 1
AskYous Avatar answered Nov 10 '22 07:11

AskYous