我有问题。我无法将迁移添加到我的ASP.NET WebAPI 2项目中。我收到错误:
“此提供程序无法使用空间类型和功能 因为程序集“Microsoft.SqlServer.Types”版本10或更高版本 无法找到。“
我知道有几个问题和答案,例如:
但是!问题是......
当我尝试运行 Add-Migration v002 时,这是完整的错误:
System.InvalidOperationException:空间类型和函数不是 可用于此提供程序,因为程序集 找不到“Microsoft.SqlServer.Types”版本10或更高版本 恩 System.Data.Entity.SqlServer.SqlTypesAssemblyLoader.GetSqlTypesAssembly() 恩 System.Data.Entity.SqlServer.SqlSpatialServices.GeographyFromText(字符串 wellKnownText)en System.Data.Entity.Spatial.DbGeography.FromText(String wellKnownText) 恩 System.Data.Entity.Migrations.Model.ColumnModel.CreateDefaultValue()
恩 System.Data.Entity.Migrations.Model.ColumnModel..ctor(PrimitiveTypeKind type,TypeUsage typeUsage)en System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.BuildColumnModel(EdmProperty property,TypeUsage conceptualTypeUsage,TypeUsage defaultStoreTypeUsage,IDictionary2 annotations) en System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.BuildColumnModel(EdmProperty property, ModelMetadata modelMetadata, IDictionary
2个注释)
恩 System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer<> c__DisplayClass2e3.b__2df(EdmProperty 钢笔 System.Data.Entity.Utilities.IEnumerableExtensions.Each [T](IEnumerable1 ts, Action
1 action)zh System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.BuildCreateTableOperation(EntitySet的 entitySet,ModelMetadata modelMetadata)en System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.b__194(EntitySet的 es)en System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
1..ctor(IEnumerable
en System.Collections.Generic.List1 collection)
1 source)zh System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(ModelMetadata source,ModelMetadata target,Lazy
en System.Linq.Enumerable.ToList[TSource](IEnumerable1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion) en System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, Lazy
1 modificationCommandTreeGenerator,MigrationSqlGenerator migrationSqlGenerator,String sourceModelVersion,String targetModelVersion)en System.Data.Entity.Migrations.DbMigrator.Scaffold(字符串 migrationName,String namespace,Boolean ignoreChanges)en System.Data.Entity.Migrations.Design.MigrationScaffolder.Scaffold(字符串 migrationName,Boolean ignoreChanges)en System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Scaffold(MigrationScaffolder 脚手架)en System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run() en System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)en System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
en System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner) 亚军) System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(字符串 migrationName,String language,String rootNamespace,Boolean ignoreChanges)en System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, 布尔力,布尔值ignoreChanges)en System.Data.Entity.Migrations.AddMigrationCommand<> c__DisplayClass2< .ctor> b__0() 恩 System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(动作 命令)
答案 0 :(得分:55)
经过大量研究后,我刚刚安装了" SQL Server 2012的Microsoft System CLR类型"从:
像魅力一样工作!
答案 1 :(得分:10)
确保您没有错过绑定重定向
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0-11.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
答案 2 :(得分:2)
这对我有用。
将其添加到web.config> system.webServer >>运行时>> assemblyBinding节点
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
答案 3 :(得分:1)
问题可能是“虚拟”。在发出add-migration命令时,您需要在bin文件夹中包含SqlServerSpatial140.dll。 只需将.dll复制到bin以进行开发,并在部署期间手动替换版本(x86 / x64)。 Sql Server(2012+)已经安装了程序集。