0

我正在尝试使用 Devart EFCore 9.8 和 MSEFCore 2.2.4 中的 Oracle 点连接试用许可证从表(oracle db 12c)中获取数据。但是 VARRAY 列没有被映射。它抛出异常 -

System.InvalidOperationException: The property 'TierInfoTemp.num_arr'
 is of type 'OracleType' which is not supported by current database 
provider. Either change the property CLR type or ignore the property
 using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.
Ignore' in 'OnModelCreating'.

我的 DBContext.cs:

protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<TierInfoTemp>(entity =>
            {
                OracleConnectionStringBuilder oraCSB = new OracleConnectionStringBuilder();
                oraCSB.Direct = true;
                oraCSB.Server = "xxx";
                oraCSB.Port = xxxx;
                oraCSB.Sid = "xxxx";
                oraCSB.UserId = "xxxx";
                oraCSB.Password = "xxx";
                entity.Property(e => e.num_arr).HasColumnType("VARRAY")
                .HasConversion<OracleType>();
            });
        }
        public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options)
        {
        }
        public virtual DbSet<TierInfoTemp> tier_info_temp { get; set; }

实体:

public class TierInfoTemp
    {
        [Column("TIER_ID")]
        [Key]
        public int tier_id { get; set; }
        [Column("TIER_NAME")]
        public string tier_name { get; set; }
        [Column("IS_ACTIVE")]
        public int is_active { get; set; }
        [Column("REGION_ID")]
        public int region_id { get; set; }
        [Column("NUM_ARR")]
        public OracleType num_arr { get; set; }  ///VARARY Field
    }

我做错什么了吗?如果需要更多详细信息,请发表评论。

4

1 回答 1

0

Devart EF Core 提供程序支持的 Oracle 数据类型列表可在https://www.devart.com/dotconnect/oracle/docs/?DataTypeMapping.html获得。

EF Core 目前不支持 OracleType,但您可以通过普通的 ADO.NET 使用它:https ://www.devart.com/dotconnect/oracle/docs/?Varray.html 。

于 2019-10-26T12:23:27.100 回答