无法找到程序集"Microsoft.SqlServer.Types"版本10或更高版本

Mar*_*tín 24 c# sql-server entity-framework azure visual-studio

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

"此提供程序无法使用空间类型和函数,因为无法找到程序集"Microsoft.SqlServer.Types"版本10或更高版本."

我知道有几个问题和答案,如:

但!问题是...

  • 我已经安装了Microsoft.SqlServer.Types.
  • 我已经将Global.asax配置为:SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("〜/ bin"))到Application_Start中.
  • 参考设置为本地副本> true.
  • NuGet包都已更新.
  • 我已经尝试降级并升级包.

当我尝试运行Add-Migration v002时,这是完整的错误:

System.InvalidOperationException:此提供程序无法使用空间类型和函数,因为无法找到程序集"Microsoft.SqlServer.Types"版本10或更高版本.
zh_cn System.Data.Entity.SqlServer.SqlTypesAssemblyLoader.GetSqlTypesAssembly()zh_cn System.Data.Entity.SqlServer.SqlSpatialServices.GeographyFromText(String wellKnownText)zh_cn System.Data.Entity.Spatial.DbGeography.FromText(String wellKnownText)zh_cn System.Data .Entity.Migrations.Model.ColumnModel.CreateDefaultValue()
zh_cn System.Data.Entity.Migrations.Model.ColumnModel..ctor(PrimitiveTypeKind type,TypeUsage typeUsage)zh_cn System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.BuildColumnModel(EdmProperty) property,TypeUsage conceptualTypeUsage,TypeUsage defaultStoreTypeUsage,IDictionary 2 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]( IEnumerable 1 ts, Action1 action)en System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.BuildCreateTableOperation(EntitySet entitySet,ModelMetadata modelMetadata)zh_cn System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.b__194(EntitySet es)en System.Linq.Enumerable.WhereSelectEnumerableIterator 1..ctor(IEnumerable 1 source)zh_cn System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(ModelMetadata source,ModelMetadata target,Lazy 1 modificationCommandTreeGenerator,MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion,String targetModelVersion)zh_cn System.Data.Entity.Migrations.DbMigrator.Scaffold(String migrationName,String namespace,Boolean ignoreChanges)zh_cn System.Data.Entity.Migrations.Design.MigrationScaffolder.Scaffold(String migrationName,Boolean ignoreChanges)zh System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Scaffold(MigrationScaffolder scaffolder)zh_cn System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run()zh_cn System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)en System. AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) zh_cn System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)en Sy stem.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(String migrationName,String language,String rootNamespace,Boolean ignoreChanges)zh_cn System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name,Boolean force,Boolean ignoreChanges)zh System .Data.Entity.Migrations.AddMigrationCommand.<> c__DisplayClass2.<.ctor> b__0()zh_cn System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)2.MoveNext()
en System.Collections.Generic.List
1 collection)
en System.Linq.Enumerable.ToList[TSource](IEnumerable
1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion) en System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, Lazy

Mar*_*tín 60

经过大量研究后,我刚从以下位置安装了"SQL Server 2012的Microsoft System CLR类型":

像魅力一样工作!

  • 这对我有用.非常感谢先生 (2认同)

R2D*_*2D2 11

确保您没有错过绑定重定向

  <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>
Run Code Online (Sandbox Code Playgroud)