2016-11-16 7 views
1

私のMACの既存のデータベースからモデルクラスをリバースエンジニアリングするために.netコアを使用しようとしています。データベースはWindowsのあるVMで実行されており、osxからそのデータベースに接続できます。私project.jsonでmacのdotnet ef coreでスキャフォールドできません

私は、次があります。

"dependencies": { 
    "Microsoft.NETCore.App": { 
     "version": "1.0.1", 
     "type": "platform" 
    }, 
    "Microsoft.AspNetCore.AngularServices": "1.0.0-*", 
    "Microsoft.AspNetCore.Diagnostics": "1.0.0", 
    "Microsoft.AspNetCore.Mvc": "1.0.1", 
    "Microsoft.AspNetCore.Razor.Tools": { 
     "version": "1.0.0-preview2-final", 
     "type": "build" 
    }, 
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", 
    "Microsoft.AspNetCore.StaticFiles": "1.0.0", 
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", 
    "Microsoft.Extensions.Configuration.Json": "1.0.0", 
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0", 
    "Microsoft.Extensions.Logging": "1.0.0", 
    "Microsoft.Extensions.Logging.Console": "1.0.0", 
    "Microsoft.Extensions.Logging.Debug": "1.0.0", 
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", 

    "Microsoft.EntityFrameworkCore.Design": { 
     "type": "build", 
     "version": "1.0.0-preview2-final" 
    }, 
    "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-rc2-final", 
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final" 
    }, 

    "tools": { 
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", 
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", 
    "Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final", 
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" 
    }, 

    "frameworks": { 
    "netcoreapp1.0": { 
     "imports": [ 
     "dotnet5.6", 
     "portable-net45+win8" 
     ] 
    } 
    }, 

    "buildOptions": { 
    "emitEntryPoint": true, 
    "preserveCompilationContext": true, 
    "compile": { 
     "exclude": ["node_modules"] 
    } 
    } 

しかし、私は

dotnet ef dbcontext scaffold "myDbConnectString" Microsoft.EntityFrameworkCore.SqlServer 

を実行したときに、私は次のエラーを取得すると、私はこの

An error occurred while calling method 'ConfigureDesignTimeServices' on startup class 

'Microsoft.EntityFrameworkCore.Scaffolding.SqlServerDesignTimeServices'. Consider using IDbContextFactory to override the initialization of the DbContext at design-time. Error: Could not load type 'Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions' from assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. System.AggregateException: One or more errors occurred. (Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Scaffolding.IScaffoldingModelFactory' while attempting to activate 'Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineeringGenerator'.) ---> System.InvalidOperationException: Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Scaffolding.IScaffoldingModelFactory' while attempting to activate 'Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineeringGenerator'. at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.PopulateCallSites(ServiceProvider provider, ISet 1 callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.CreateCallSite(ServiceProvider provider, ISet 1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetResolveCallSite(IService service, ISet 1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetServiceCallSite(Type serviceType, ISet 1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType, ServiceProvider serviceProvider) at System.Collections.Concurrent.ConcurrentDictionaryExtensions.GetOrAdd[TKey,TValue,TArg](ConcurrentDictionary 2 dictionary, TKey key, Func 3 valueFactory, TArg arg) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Microsoft.EntityFrameworkCore.Design.DatabaseOperations.ReverseEngineerAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable 1 schemas, IEnumerable 1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Design.Internal.OperationExecutor.ReverseEngineerAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable 1 schemaFilters, IEnumerable 1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Tools.Cli.DbContextScaffoldCommand.d__1.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task 1.GetResultCore(Boolean waitCompletionNotification) at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at Microsoft.EntityFrameworkCore.Tools.Cli.Program.Main(String[] args) ---> (Inner Exception #0) System.InvalidOperationException: Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Scaffolding.IScaffoldingModelFactory' while attempting to activate 'Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineeringGenerator'. at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.PopulateCallSites(ServiceProvider provider, ISet 1 callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) at Microsoft.Extensions.DependencyInjection.ServiceLookup.Service.CreateCallSite(ServiceProvider provider, ISet 1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetResolveCallSite(IService service, ISet 1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetServiceCallSite(Type serviceType, ISet 1 callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(Type serviceType, ServiceProvider serviceProvider) at System.Collections.Concurrent.ConcurrentDictionaryExtensions.GetOrAdd[TKey,TValue,TArg](ConcurrentDictionary 2 dictionary, TKey key, Func 3 valueFactory, TArg arg) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Microsoft.EntityFrameworkCore.Design.DatabaseOperations.ReverseEngineerAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable 1 schemas, IEnumerable 1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Design.Internal.OperationExecutor.ReverseEngineerAsync(String provider, String connectionString, String outputDir, String dbContextClassName, IEnumerable 1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Tools.Cli.DbContextScaffoldCommand.d__1.MoveNext()<--- One or more errors occurred. (Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Scaffolding.IScaffoldingModelFactory' while attempting to activate 'Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineeringGenerator'.)

に合格し取得することはできません

私は依存関係のバージョンを前後に変更しようとしましたが、結果はありません。誰もが何か指摘を受けた?

答えて

0

ちょうど動作するようにしました。 .netコア1.1.0にアップデートし、新しいバージョンを使用するようにproject.jsonを変更しました。

"dependencies": { 
    "Microsoft.NETCore.App": { 
    "version": "1.1.0", 
    "type": "platform" 
    }, 
    "Microsoft.AspNetCore.AngularServices": "1.0.0-*", 
    "Microsoft.AspNetCore.Diagnostics": "1.1.0", 
    "Microsoft.AspNetCore.Mvc": "1.1.0", 
    "Microsoft.AspNetCore.Razor.Tools": { 
    "version": "1.1.0-preview4-final", 
    "type": "build" 
    }, 
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", 
    "Microsoft.AspNetCore.StaticFiles": "1.1.0", 
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", 
    "Microsoft.Extensions.Configuration.Json": "1.1.0", 
    "Microsoft.Extensions.Configuration.CommandLine": "1.1.0", 
    "Microsoft.Extensions.Logging": "1.1.0", 
    "Microsoft.Extensions.Logging.Console": "1.1.0", 
    "Microsoft.Extensions.Logging.Debug": "1.1.0", 
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0", 

    "Microsoft.EntityFrameworkCore.Design": { 
    "type": "build", 
    "version": "1.1.0" 
    }, 
    "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0", 
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0" 
}, 

"tools": { 
    "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final", 
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final", 
    "Microsoft.DotNet.Watcher.Tools": "1.1.0-preview4-final", 
    "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final" 
} 
0

RTM版のEntity Frameworkを使用してみましたか?

{ 
    "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.1", 
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.1" 
} 
+0

れていないもののバージョンが、私はちょうどそれが動作するようになった。これは他の誰かが

project.json役立つことを願って。おそらく他の誰かを助けるために私の新しいproject.jsonを投稿します –

関連する問題