简体   繁体   English

使用空间类型EF CORE创建模型

[英]Create a model Using Spatial types EF CORE

i know that the entity framework team has delayed the spatial types support, but is there a way to tell entity framework to create a column of Geography type for a specified entity? 我知道实体框架团队已经延迟了空间类型支持,但有没有办法告诉实体框架为指定实体创建一个Geography类型列?

i'll make the querys using the .FromSql(String) method, but i want teh model build completely from Entity Framework. 我将使用.FromSql(String)方法进行查询,但我希望完全从Entity Framework构建模型。

You can do that by setting the type in either you migration or with the column attribute here is an example: 您可以通过在迁移中设置类型或使用列属性来执行此操作,这是一个示例:

        [Column(TypeName ="sys.Geography")]
        public string Geography { get; set; }

With this Update and create work fine, but reading is tricky because EF doesn't won't be able to handle the type. 使用此更新并创建工作正常,但读取是棘手的,因为EF将无法处理该类型。 Here is how I get around that mess altogether . 这是我如何彻底解决这个烂摊子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM