I am being told to use Microsoft.SqlServer.Types
for DbGeography
in a homework project I have. The homework project is with ASP.NET, and is trying to use a database to do a search on stuff in the db. (The database is supposed to be from a .bak
file, but I had to upload a .bacpac
file into azure and then connect back to it, since the .bak
file keeps saying it's corrupt).
This is a code block that I have been told to put into the Global.asax.cs
file:
protected void Application_Start()
{
// For Spatial types, i.e. DbGeography
SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
// This next line is a fix that came from: https://stackoverflow.com/questions/13174197/microsoft-sqlserver-types-version-10-or-higher-could-not-be-found-on-azure/40166192#40166192
SqlProviderServices.SqlServerTypesAssemblyName = typeof (SqlGeography).Assembly.FullName;
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
I have looked at the documentation, and the darned thing just says:
Microsoft.SqlServer.Types
Allows you to use SQL Server spatial types on a machine without SQL Server installed. Enables Entity Framework spatial types to be used (DbGeography and DbGeometry).
Which I think just means that this package enables us to use c expression for SQL, but I would like a better explanation. I have no clue what DbGeography
and DbGeometry
do.
Additionally, I would like to know if this is applicable to an azure-based db, and not just a local db made from a .bak file.