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?
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
I had this issue also. My solution was to install the nuget package Microsoft.Extensions.Configuration.UserSecrets
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With