提问人:GökhanDoğru 提问时间:11/16/2023 更新时间:11/16/2023 访问量:29
PostgreSQL - NetTopologySuite 和 ABP.IO - 不支持映射问题
PostgreSQL - NetTopologySuite & ABP.IO - Not support mapping problems
问:
我按照文档中进行了添加,但是当我进行dotnet ef迁移时出现错误。 abp.io v7.3.3 和 PostgreSQL
站.cs
[Column(TypeName="geography")]
public virtual Point Location { get; set; }
DbContext.xs
protected override void OnModelCreating(ModelBuilder builder)
{
...
/* Include modules to your migration db context */
builder.HasPostgresExtension("postgis");
builder.Entity<Station>().Property(b => b.Location).HasColumnType("geography");
...
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
var dataSourceBuilder = new NpgsqlDataSourceBuilder("Host=localhost;Port=5432;Database=SarJz;User ID=postgres;Password=myPassw0rd;");
dataSourceBuilder.UseNetTopologySuite();
var dataSource = dataSourceBuilder.Build();
context.Services.AddDbContext<SarJzDbContext>(options =>
options.UseNpgsql(dataSource, o => o.UseNetTopologySuite()));
}
但我仍然收到这个错误;
dotnet ef migrations add RenewedStationGeometry
Build started...
Build succeeded.
The Entity Framework tools version '7.0.5' is older than that of the runtime '7.0.11'. Update the tools for the latest features and bug fixes. See https://aka.ms/AAc1fbw for more information.
System.InvalidOperationException: The 'Point' property 'Station.Location' could not be mapped to the database type 'geography' because the database provider does not support mapping 'Point' properties to 'geography' columns. Con
sider mapping to a different database type or converting the property value to a type supported by the database using a value converter. See https://aka.ms/efcore-docs-value-converters for more information. Alternately, exclude
the property from the model using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
我对文档做了同样的事情,没有任何变化。
答: 暂无答案
评论