Repository navigation
Closed as not planned
Description
The Package Manager Console powershell commands does not currently work on projects using csproj.
Issues:
- OperationHandlers.cs does not compile. (Fix already in Fix powershell commands #5037 )
- Cannot new-up a DbContext at design time due to "MissingMethodException" in
MemoryCacheServiceCollectionExtensions
Repro
File -> New Project... (Console App)
Add this a simple dbcontext.
public class TestContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("Database=test;Server=(localdb)\\mssqllocaldb");
}
}
From PMC
Install-Package Microsoft.EntityFrameworkCore.SqlServer -Pre -Source https://www.myget.org/F/aspnetcirelease/
Install-Package Microsoft.EntityFrameworkCore.Commands -Pre -Source https://www.myget.org/F/aspnetcirelease/
Add-Migration FirstMigration
First error looks like
The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: c:\Users\namc\Documents\Visual Studio 2015\Projects\ClassLibrary2\packages\Microsoft.EntityFrameworkCore.Commands.1.0.0-rc2-20529\tools\OperationHandlers.cs(35) : ; expected
c:\Users\namc\Documents\Visual Studio 2015\Projects\ClassLibrary2\packages\Microsoft.EntityFrameworkCore.Commands.1.0.0-rc2-20529\tools\OperationHandlers.cs(34) :
c:\Users\namc\Documents\Visual Studio 2015\Projects\ClassLibrary2\packages\Microsoft.EntityFrameworkCore.Commands.1.0.0-rc2-20529\tools\OperationHandlers.cs(35) : >>> public virtual int Version => 0;
c:\Users\namc\Documents\Visual Studio 2015\Projects\ClassLibrary2\packages\Microsoft.EntityFrameworkCore.Commands.1.0.0-rc2-20529\tools\OperationHandlers.cs(36) :
When OperationHandler.cs is fixed, the error is:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.MissingMethodException: Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Extensions.DependencyInjection.MemoryCacheServiceCollectionExtensions.AddMemoryCache(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.
at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServiceCollectionExtensions.AddQuery(IServiceCollection serviceCollection)
at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServiceCollectionExtensions.AddEntityFramework(IServiceCollection serviceCollection)
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.<>c__DisplayClass4_0.<GetOrAdd>b__1(Int64 k)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd(IDbContextOptions options)
at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
at Microsoft.EntityFrameworkCore.DbContext..ctor()
at ClassLibrary2.TestContext..ctor()
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.EntityFrameworkCore.Design.DbContextOperations.<>c__DisplayClass11_3.<FindContextTypes>b__13()
at Microsoft.EntityFrameworkCore.Design.DbContextOperations.CreateContext(Func`1 factory)
at Microsoft.EntityFrameworkCore.Design.DbContextOperations.CreateContext(String contextType)
at Microsoft.EntityFrameworkCore.Design.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_1.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-][rc2] Powershell do not work on csproj[/-][+][rc2] Powershell commands do not work on csproj[/+]natemcmaster commentedon Apr 11, 2016
cc @divega I started a little investigation, but couldn't find a reason for this bug.
BradBarnich commentedon Apr 12, 2016
Additionally, on VS15 I get this:
With VS2015, on a csproj, build 1.0.0-rc3-20540, Add-Migration does work with the changes to
OperationHandlers.csnatemcmaster commentedon Apr 12, 2016
@BradBarnich thanks for sharing. What happens if you try RC2 bits? Install from https://www.nuget.org/F/aspnetcirelease/
BradBarnich commentedon Apr 12, 2016
@natemcmaster used 1.0.0-rc2-20539, same result. With the fixes to
OperationHandlers.cs, VS2015 works and VS15 does not.natemcmaster commentedon Apr 12, 2016
@BradBarnich the issue you are seeing in VS15 Preview is the likely the same issue added here: NuGet/Home#2162. As you'll see, the issue was closed because it is a bug in VS itself.
natemcmaster commentedon Apr 12, 2016
Update: with fixes to OperationHandler.cs, the error does not reproduce on all machines. I tried on a clean install of VS2015.
[-][rc2] Powershell commands do not work on csproj[/-][+]Powershell commands do not work on csproj[/+]natemcmaster commentedon Apr 12, 2016
Closed via #5037