c# - 找不到程序集 'Microsoft.SqlServer.Types' 版本 10 或更高版本

标签 c# sql-server visual-studio entity-framework azure

我有一个问题。我无法将迁移添加到我的 ASP.NET WebAPI 2 项目。我收到错误:

"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。
  • 我已经在 Application_Start 中配置了 Global.asax:SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"))
  • 引用设置为本地副本 > true。
  • NuGet 软件包已全部更新。
  • 我已经尝试降级和升级该软件包。

当我尝试运行Add-Migration 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, IDictionary2 annotations)
en System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.<>c__DisplayClass2e3.b__2df(EdmProperty p) en System.Data.Entity.Utilities.IEnumerableExtensions.Each[T](IEnumerable1 ts, Action1 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()<br/> en System.Collections.Generic.List1..ctor(IEnumerable1 collection)<br/> en System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) en System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(ModelMetadata source, ModelMetadata target, Lazy1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion) en System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, Lazy1 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)

最佳答案

经过大量研究,我刚刚安装了“Microsoft System CLR Types for SQL Server 2012”:

效果非常好!

关于c# - 找不到程序集 'Microsoft.SqlServer.Types' 版本 10 或更高版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43221467/

相关文章:

c# - 如何使用 C# 将一个文件从 Azure 文件共享中的一个文件夹复制到另一个文件夹?

sql-server - 为什么 redshift 不接受我的固定宽度文本文件

sql-server - 在值范围层上分配值

c - 用C语言替换一个字母的程序

c# - 多个对象的随机数生成

c# - .NET HashSet 的内部实现包含方法?

c# - 通过windows服务同步MySQL和MSSQL数据库

asp.net - 更新到 VS 2015 Update 3 后调试网站项目时未命中断点

visual-studio - Nuget - "Name cannot begin with the ' <'字符

c# - 删除 "if"语句时出现问题