Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

UserSecrets causes design-time tools to crash #543

Closed
natemcmaster opened this issue Nov 3, 2016 · 4 comments
Closed

UserSecrets causes design-time tools to crash #543

natemcmaster opened this issue Nov 3, 2016 · 4 comments

Comments

@natemcmaster
Copy link
Contributor

Changes made to support MSBuild #525 attribute break design-time usages of .AddUserSecrets() because Assembly.GetEntryAssembly() is different at design-time than runtime.

Known design-time scenarios affected
EF migrations - see dotnet/efcore#6918
ASP.NET Scaffolding

Workaround:
Users should specify the app assembly with the overload of .AddUserSecrets(Assembly assembly)
Example

.AddUserSecrets(typeof(Startup).GetTypeInfo().Assembly)
@davidfowl
Copy link
Member

This is pretty horrible...

@natemcmaster
Copy link
Contributor Author

@davidfowl proposed mitigation: #544. Basically, we shouldn't make .AddUserSecrets() the default method anymore. IMO we should obsolete it.

@Eilon
Copy link
Member

Eilon commented Nov 10, 2016

This patch fix is approved!

@natemcmaster
Copy link
Contributor Author

natemcmaster commented Nov 10, 2016

Resolved in #544. Design-time operations may still throw an error about either (1) entry assembly is null or (2) the UserSecretIdAttribute could not be found, but after looking at the options, we determined that for 1.0/1.1 there isn't much more .AddUserSecrets() can do to locate the user secret ID. We will consider revisiting this in 2.0 (see #550)

In most cases, uses will want to start using .AddUserSecrets<Startup>() instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants