[{"data":1,"prerenderedAt":336},["ShallowReactive",2],{"tag-mvc":3},{"tag":4,"articles":8},{"name":5,"description":6,"img":7},"mvc","Technical articles tagged mvc.","\u002Fimg\u002Fbg44.jpg",[9,156],{"id":10,"title":11,"author":12,"body":13,"createdAt":144,"description":145,"extension":146,"img":147,"meta":148,"navigation":149,"path":150,"seo":151,"stem":152,"tags":153,"updatedAt":144,"__hash__":155},"articles\u002Farticles\u002Fmicrosoft-sqlserver-types-getting-it-done.md","Microsoft.SqlServer.Types–Getting it done.","[object Object]",{"type":14,"value":15,"toc":142},"minimark",[16,25,39,107,113,116,121,124,127,138],[17,18,19,20,24],"p",{},"Recently, started working with SQL Server GeoSpatial types. Specifically I am using column type ",[21,22,23],"strong",{},"geography. ","\nAll was working fine when using on localhost web site however after deployment to a test environment, I go the following exception.",[17,26,27,28,31,32,35,38],{},"Initially, I thought something was not installed on the server (could still be) however the following is the exception and the resolution. Exception:",[29,30],"br",{},"\nSystem.InvalidOperationException: Spatial types and functions are not available for this provider because the assembly ",[21,33,34],{},"'Microsoft.SqlServer.Types'",[21,36,37],{},"version 10 or higher could not be found",".",[40,41,46],"pre",{"className":42,"code":43,"language":44,"meta":45,"style":45},"language-html shiki shiki-themes github-light github-dark","at System.Data.Entity.SqlServer.SqlTypesAssemblyLoader.GetSqlTypesAssembly() \nat System.Data.Entity.SqlServer.SqlSpatialDataReader.\u003C.cctor>b__0() at System.Lazy`1.CreateValue() \n--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Lazy`1.get_Value()\nat System.Data.Entity.SqlServer.SqlSpatialDataReader.GetGeography(Int32 ordinal) at\nSystem.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal) at\nSystem.Data.Entity.Core.Common.Internal.Materialization.Shaper.GetSpatialPropertyValueWithErrorHandling[TProperty](Int32 ordinal, String propertyName, String \ntypeName, PrimitiveTypeKind spatialTypeKind) at lambda_method(Closure , Shaper ) Resolution: To include in your project for deployment purposes, \nuse nuget to get Microsoft.SqlServer.Types package. \n","html","",[47,48,49,58,71,77,83,89,95,101],"code",{"__ignoreMap":45},[50,51,54],"span",{"class":52,"line":53},"line",1,[50,55,57],{"class":56},"sVt8B","at System.Data.Entity.SqlServer.SqlTypesAssemblyLoader.GetSqlTypesAssembly() \n",[50,59,61,64,68],{"class":52,"line":60},2,[50,62,63],{"class":56},"at System.Data.Entity.SqlServer.SqlSpatialDataReader.",[50,65,67],{"class":66},"s7hpK","\u003C",[50,69,70],{"class":56},".cctor>b__0() at System.Lazy`1.CreateValue() \n",[50,72,74],{"class":52,"line":73},3,[50,75,76],{"class":56},"--- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Lazy`1.get_Value()\n",[50,78,80],{"class":52,"line":79},4,[50,81,82],{"class":56},"at System.Data.Entity.SqlServer.SqlSpatialDataReader.GetGeography(Int32 ordinal) at\n",[50,84,86],{"class":52,"line":85},5,[50,87,88],{"class":56},"System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal) at\n",[50,90,92],{"class":52,"line":91},6,[50,93,94],{"class":56},"System.Data.Entity.Core.Common.Internal.Materialization.Shaper.GetSpatialPropertyValueWithErrorHandling[TProperty](Int32 ordinal, String propertyName, String \n",[50,96,98],{"class":52,"line":97},7,[50,99,100],{"class":56},"typeName, PrimitiveTypeKind spatialTypeKind) at lambda_method(Closure , Shaper ) Resolution: To include in your project for deployment purposes, \n",[50,102,104],{"class":52,"line":103},8,[50,105,106],{"class":56},"use nuget to get Microsoft.SqlServer.Types package.\n",[17,108,109],{},[110,111],"img",{"alt":45,"src":112},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-spatial-types-and-functions-are-not-avai_a814-sqlservertypenuget_2.jpg",[17,114,115],{},"After the package is installed, the following readme will give you details for both ASP.NET and Desktop applications.",[17,117,118],{},[110,119],{"alt":45,"src":120},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-spatial-types-and-functions-are-not-avai_a814-actionrequired_2.jpg",[17,122,123],{},"To deploy an application that uses spatial data types to a machine that does not have 'System CLR Types\nfor SQL Server' installed you also need to deploy the native assembly SqlServerSpatial110.dll.Both x86 (32 bit) and x64 (64 bit) versions of this assembly have been added to your project under the SqlServerTypes\\x86 and SqlServerTypes\\x64 subdirectories.",[17,125,126],{},"The native assembly msvcr100.dll is also included  in case the C++runtime is not installed.  Adding the following to the Global.asax.cs Application_Start()",[40,128,132],{"className":129,"code":130,"language":131,"meta":45,"style":45},"language-csharp shiki shiki-themes github-light github-dark","SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath(\"~\u002Fbin\"));\n","csharp",[47,133,134],{"__ignoreMap":45},[50,135,136],{"class":52,"line":53},[50,137,130],{},[139,140,141],"style",{},"html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s7hpK, html code.shiki .s7hpK{--shiki-default:#B31D28;--shiki-default-font-style:italic;--shiki-dark:#FDAEB7;--shiki-dark-font-style:italic}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":45,"searchDepth":60,"depth":60,"links":143},[],"2020-06-11T20:28:49.852Z","SQL Server GeoSpatial types","md","\u002Farticles\u002Fimages\u002Fwindows-live-writer-spatial-types-and-functions-are-not-avai_a814-sqlservertypenuget_thumb.jpg",{},true,"\u002Farticles\u002Fmicrosoft-sqlserver-types-getting-it-done",{"title":11,"description":145},"articles\u002Fmicrosoft-sqlserver-types-getting-it-done",[5,154],"sqlserver","1dmx9etHvwEb9Xf4khJPeF6FdCgWY2eXe5VWYxfvRO4",{"id":157,"title":158,"author":12,"body":159,"createdAt":327,"description":328,"extension":146,"img":328,"meta":329,"navigation":149,"path":330,"seo":331,"stem":332,"tags":333,"updatedAt":327,"__hash__":335},"articles\u002Farticles\u002Fupgrading-to-mvc-4-from-prior-versions.md","Upgrading to MVC 4 (from prior versions)",{"type":14,"value":160,"toc":325},[161,170,183,191,194,207,210,215,250,264,267,270,273,311,322],[17,162,163,164,166,167,169],{},"MVC 4 will happily run alongside ASP.NET MVC version 3 and .NET 4\u002FVS2010. You can thus experiment and create MVC 4 projects without fear of breaking your old applications.",[29,165],{},"\n ",[29,168],{},"\n There are three main methods of upgrading to MVC 4:",[171,172,173,177,180],"ul",{},[174,175,176],"li",{},"Copy existing content into a new MVC 4 project",[174,178,179],{},"Manually upgrade the project",[174,181,182],{},"Utilize the MVC 4 NuGet package (by applying the Microsoft.AspNet.MVC package)",[17,184,185,186,166,188,190],{}," Manual Upgrade Steps:",[29,187],{},[29,189],{},"\nOpen up all the web.config files in your project and replace any lines that read as the following:",[40,192,193],{},"System.Web.Mvc, Version=3.0.0.0  \nSystem.Web.WebPages, Version=1.0.0.0  \nSystem.Web.Helpers, Version=1.0.0.0  \nSystem.Web.WebPages.Razor, Version=1.0.0.0",[17,195,196,197,166,199,201,202,204,205,166],{},"With their MVC 4 counterparts:",[29,198],{},[29,200],{},"\nSystem.Web.Mvc, Version=4.0.0.0\nSystem.Web.WebPages, Version=2.0.0.0\nSystem.Web.Helpers, Version=2.0.0.0,\nSystem.Web.WebPages.Razor, Version=2.0.0.0,",[29,203],{},"\nIn the root web.config file, add a new PreserveLoginUrl key entry:",[29,206],{},[40,208,209],{},"\u003CappSettings>  \n  \u003Cadd key=\"webpages:Version\" value=\"2.0.0.0\" \u002F>  \n  \u003Cadd key=\"PreserveLoginUrl\" value=\"true\" \u002F>  \n\u003CappSettings>",[17,211,212,213,166],{},"Now delete any references to System.Web.MVC (v3). In Solution Explorer, remove the following assembly references:",[29,214],{},[171,216,217,220,223,226,229,232,235,238,241,244,247],{},[174,218,219],{},"System.Web.Mvc (v3.0.0.0)",[174,221,222],{},"System.Web.WebPages (v1.0.0.0)",[174,224,225],{},"System.Web.Razor (v1.0.0.0)",[174,227,228],{},"System.Web.WebPages.Deployment (v1.0.0.0)",[174,230,231],{},"System.Web.WebPages.Razor (v1.0.0.0)",[174,233,234],{},"Now add references to the new versions of these assemblies:",[174,236,237],{},"System.Web.Mvc (v4.0.0.0)",[174,239,240],{},"System.Web.WebPages (v2.0.0.0)",[174,242,243],{},"System.Web.Razor (v2.0.0.0)",[174,245,246],{},"System.Web.WebPages.Deployment (v2.0.0.0)",[174,248,249],{},"System.Web.WebPages.Razor (v2.0.0.0)",[17,251,252,253,255,256,258,259,261,262,166],{},"In Solution Explorer, unload your MVC project as we are going to make some changes to the project file; this won't work if the solution is open.",[29,254],{},"\nOpen the project file  and replace any references of the ProjectTypeGuids E53F8FEA-EAE0-44A6-8774-FFD645390401 with E3E379DF-F4C6-4180-9B81-6769533ABE47.",[29,257],{},"\nSave the changes you have made and reload the project.",[29,260],{},"\nFinally, if your application or its references uses any assemblies compiled against the previous version of MVC, tell these to use MVC4 by adding binding redirect entries such as the following:",[29,263],{},[40,265,266],{},"\u003Cconfiguration>  \n  \u003Cruntime>  \n    \u003CassemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">  \n      \u003CdependentAssembly>  \n        \u003CassemblyIdentity name=\"System.Web.Helpers\"  \n             publicKeyToken=\"31bf3856ad364e35\" \u002F>  \n        \u003CbindingRedirect oldVersion=\"1.0.0.0\" newVersion=\"2.0.0.0\"\u002F>  \n      \u003C\u002FdependentAssembly>  \n      \u003CdependentAssembly>  \n        \u003CassemblyIdentity name=\"System.Web.Mvc\"  \n             publicKeyToken=\"31bf3856ad364e35\" \u002F>  \n        \u003CbindingRedirect oldVersion=\"1.0.0.0-3.0.0.0\" newVersion=\"4.0.0.0\"\u002F>  \n      \u003C\u002FdependentAssembly>  \n      \u003CdependentAssembly>  \n        \u003CassemblyIdentity name=\"System.Web.WebPages\"  \n             publicKeyToken=\"31bf3856ad364e35\" \u002F>  \n        \u003CbindingRedirect oldVersion=\"1.0.0.0\" newVersion=\"2.0.0.0\"\u002F>  \n      \u003C\u002FdependentAssembly>  \n    \u003C\u002FassemblyBinding>  \n  \u003C\u002Fruntime>  \n\u003C\u002Fconfiguration>",[40,268,269],{}," ",[17,271,272],{},"Notes:",[171,274,275,278,281,284,287,290,293,296,299,302,305,308],{},[174,276,277],{},"I had to do similar updates to the web.config located in the Views directory",[174,279,280],{},"If after you build and browse to the home page, you get errors like ‘The type or namespace {fill in} does not exist in the namespace..you are missing an assembly reference’ you may need to set ‘Copy Local = True’ on a few of the references.  In particular I had to set to True for the following assemblies:",[174,282,283],{},"Microsoft.Web.Infrastructure",[174,285,286],{},"System.Web.Helpers",[174,288,289],{},"System.Web.Http",[174,291,292],{},"System.Web.Http.WebHost",[174,294,295],{},"System.Web.Mvc",[174,297,298],{},"System.Web.Razor",[174,300,301],{},"System.Web.WebPages",[174,303,304],{},"System.Web.WebPages.Deployment",[174,306,307],{},"System.Web.WebPages.Razor",[174,309,310],{},"WebGrease",[17,312,313,314,318],{},"ASP.NET MVC 4 new features - ",[315,316],"a",{"title":317,"href":317},"http:\u002F\u002Fwww.asp.net\u002Fwhitepapers\u002Fmvc4-release-notes",[315,319,317],{"href":317,"rel":320},[321],"nofollow",[17,323,324],{},"Note: Also note .NET 4.5 is an extension to 4.0, it does not introduce a new runtime",{"title":45,"searchDepth":60,"depth":60,"links":326},[],"2015-04-20T08:07:12.3800000-04:00",null,{},"\u002Farticles\u002Fupgrading-to-mvc-4-from-prior-versions",{"title":158,"description":328},"articles\u002Fupgrading-to-mvc-4-from-prior-versions",[334,5],"aspnet","GE11lDkpA4HwyWPf4GsE5CSacjnBx_Va3XEsyjiSaN8",1781574762918]