未找到注释“SqlServer:Include”。确保注释已添加 ASP.Net MVC
Posted
技术标签:
【中文标题】未找到注释“SqlServer:Include”。确保注释已添加 ASP.Net MVC【英文标题】:The annotation 'SqlServer:Include' was not found. Ensure that the annotation has been added ASP.Net MVC 【发布时间】:2020-01-24 21:37:21 【问题描述】:我有一个 asp.net MVC Code 第一个项目。 当我在 Nuget 控制台中运行此命令时:
“更新数据库”
它返回此错误:
PM> update-database
Applying migration '20180623170538_natinalCode'.
System.InvalidOperationException: The annotation 'SqlServer:Include' was not found. Ensure that the annotation has been added.
at Microsoft.EntityFrameworkCore.Infrastructure.AnnotatableExtensions.GetAnnotation(IAnnotatable annotatable, String annotationName)
at Microsoft.EntityFrameworkCore.Migrations.SqlServerMigrationsSqlGenerator.<GetIndexesToRebuild>d__48.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.EntityFrameworkCore.Migrations.SqlServerMigrationsSqlGenerator.Generate(AlterColumnOperation operation, IModel model, MigrationCommandListBuilder builder)
at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(MigrationOperation operation, IModel model, MigrationCommandListBuilder builder)
at Microsoft.EntityFrameworkCore.Migrations.MigrationsSqlGenerator.Generate(IReadOnlyList`1 operations, IModel model)
at Microsoft.EntityFrameworkCore.Migrations.SqlServerMigrationsSqlGenerator.Generate(IReadOnlyList`1 operations, IModel model)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateUpSql(Migration migration)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
The annotation 'SqlServer:Include' was not found. Ensure that the annotation has been added.
PM>
这个项目不是核心......
我该怎么办?
感谢您的回复...
【问题讨论】:
你把'SqlServer:Include'
添加到哪里了?
@LinkedListT 我没有在我的项目中找到“SqlServer:Include”。
您可以将更改后的模型也添加到问题中吗?!
【参考方案1】:
将 Microsoft.EntityFrameworkCore 、Microsoft.EntityFrameworkCore.SqlServer 和 Microsoft.EntityFrameworkCore.Tools 更新到 2.2.0 或更高版本:)
【讨论】:
以上是关于未找到注释“SqlServer:Include”。确保注释已添加 ASP.Net MVC的主要内容,如果未能解决你的问题,请参考以下文章