我有一个现有的Azure CosmosDB,里面有所有的数据和集合。现在,我希望基于我对SQLServer数据库所做的相同过程来生成模型类。
https://www.learnentityframeworkcore.com/walkthroughs/existing-database
我尝试了以下命令,使用cmd实用程序导航到包含解决方案文件的文件夹:
dotnet ef dbcontext scaffold <Azure CosmosDB ConnectionString> Microsoft.EntityFrameworkCore.Cosmos -o Models在执行上面的命令时,我得到以下错误:
System.InvalidOperationException: Unable to find expected assembly attribute named DesignTimeProviderServicesAttribute in provider assembly Microsoft.EntityFrameworkCore.Cosmos. This attribute is required to identify the class which acts as the design-time service provider factory.
at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.ConfigureProviderServices(String provider, IServiceCollection services, Boolean throwOnError)
at Microsoft.EntityFrameworkCore.Design.Internal.DesignTimeServicesBuilder.Build(String provider)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>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)
Unable to find expected assembly attribute named DesignTimeProviderServicesAttribute in provider assembly Microsoft.EntityFrameworkCore.Cosmos. This attribute is required to identify the class which acts as the design-time service provider factory.有人能帮助我知道如何解决这个问题吗?
发布于 2019-10-03 01:44:29
为了使其正常工作,数据库提供程序需要包含有关如何进行搭建的信息。目前,CosmosDB不支持此功能,因此您将无法使用命令行界面从现有数据库创建模型。
有一个Github issue open可以改进错误消息,使这一点更加清楚。如果你愿意,你可以在该repo上打开一个问题,请求为Cosmos添加该功能。
https://stackoverflow.com/questions/58185011
复制相似问题