我遇到问题。我无法将迁移添加到我的ASP.NET WebAPI 2项目。我得到错误:Assembly'Microsoft.SqlServer.Types'版本10或更高版本无法找到
"Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found."
我知道有几个问题和解答关于这一点,像:
- 'Microsoft.SqlServer.Types' version 10 or higher could not be found on Azure
- "Spatial types and functions are not available" error when converting a string to DbGeometry in ASP.NET
但是!问题是...
- 我已经安装了Microsoft.SqlServer.Types。
- 我已经将Global.asax配置为:SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath(“〜/ bin”))进入Application_Start。
- 引用设置为本地复制> true。
- NuGet软件包全部更新。
- 我已经尝试降级并升级包装。
这是完整的错误,当我尝试例如添加迁移V002运行:
System.InvalidOperationException: Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found.
en System.Data.Entity.SqlServer.SqlTypesAssemblyLoader.GetSqlTypesAssembly() en System.Data.Entity.SqlServer.SqlSpatialServices.GeographyFromText(String wellKnownText) en System.Data.Entity.Spatial.DbGeography.FromText(String wellKnownText) en System.Data.Entity.Migrations.Model.ColumnModel.CreateDefaultValue()
en 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 annotations)
en System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.<>c__DisplayClass2e3.b__2df(EdmProperty p) en System.Data.Entity.Utilities.IEnumerableExtensions.Each[T](IEnumerable1 ts, Action
1 action) en 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) en 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(String migrationName, String namespace, Boolean ignoreChanges) en System.Data.Entity.Migrations.Design.MigrationScaffolder.Scaffold(String migrationName, Boolean ignoreChanges) en System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Scaffold(MigrationScaffolder scaffolder) 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 runner) en System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(String migrationName, String language, String rootNamespace, Boolean ignoreChanges) en System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges) en System.Data.Entity.Migrations.AddMigrationCommand.<>c__DisplayClass2.<.ctor>b__0() en System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
这个工作在新机器上,其中使用EDMX(我恨,如果我要使用EF一个项目,我要去与代码第一)....这是炸毁,我以前的机器2个星期前有相同版本的视觉工作室,2015年等。所以除了我在这台新机器上第一次安装sql server 2016 ...那是唯一不同的东西,所以我很高兴我找到了你的答案,对我来说,因为我和其他几个人在同一个项目中从来没有遇到过这个问题......看到这件事非常令人沮丧。 Thx –
Omg,谢谢。我一直在滔滔不绝,而且我发现的有关下载用于sql类型的nuget的其他所有内容都无效,因为我的实体位于单独的项目/程序集中。所以,当我试图做任何移植的东西,它失败了。安装CLR MSI后,一切正常。 – jmichas
最后这个为我工作。 – Tawani