地图的Guid属性甲骨文在实体框架$ C C首先$甲骨文、实体、框架、属性

2023-09-03 21:47:23 作者:怪性酷男人

我试图映射一个GUID属性甲骨文。下面是它的声明:

I am trying to map a Guid property to Oracle. Here's its declaration:

[Key]
[Column(Order = 0, TypeName = "RAW")]
[MaxLength(16)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public Guid Id { get; set; }

不过,我不断收到以下异常:

However, I keep getting the following exception:

指定的架构是无效的。错误:

Schema specified is not valid. Errors:

(7,12):错误2019:​​指定的成员映射无效。类型Edm.Guid [可空=假,默认值='成员'身份证'的类型为Model.Test'是不符合OracleEFProvider.raw [可空=假,默认值=,最大长度= 2000,定长=假兼容'成员'身份证'类型'codeFirstDatabaseSchema.Test'。

(7,12) : error 2019: Member Mapping specified is not valid. The type 'Edm.Guid[Nullable=False,DefaultValue=]' of member 'Id' in type 'Model.Test' is not compatible with 'OracleEFProvider.raw[Nullable=False,DefaultValue=,MaxLength=2000,FixedLength=False]' of member 'Id' in type 'CodeFirstDatabaseSchema.Test'.

我在想什么?

谢谢!

RP

推荐答案

我已经放弃了,因为我没有从Oracle或微软的回应。据我所知,有没有办法让实体框架code首先使用GUID的甲骨文。 我使用一个字符串代替的Guid,但我还是有Guid.NewGuid()来填充它。toString()方法,让我有一个唯一的主键。

I have given up, since I got no response from either Oracle or Microsoft. As far as I can tell, there is no way to have Entity Framework Code First use Guids on Oracle. I am using a String instead of the Guid, but I still populate it with a Guid.NewGuid().ToString(), so that I have a unique primary key.