[英]The 'Id' property on 'Table1' could not be set to a 'System.Byte[]' value. You must set this property to a non-null value of type 'System.Guid'
I am using Code First with Oracle 12c
. 我在Oracle 12c
使用Code First。 I have a class 我有一堂课
public class Table1
{
public Guid Id { get; set; }
public string SomeOtherStuff { get; set; }
}
Entity Framework converts Id to RAW
实体框架将ID转换为RAW
CREATE TABLE "FB"."Media"
( "Id" RAW(16) NOT NULL ENABLE, ...
So now if I do this: 所以现在如果我这样做:
var list = db.Table1.SqlQuery("select * from Table1")).ToList();
I get an error 我得到一个错误
The 'Id' property on 'Table1' could not be set to a 'System.Byte[]' value. 无法将“表1”上的“ Id”属性设置为“ System.Byte []”值。 You must set this property to a non-null value of type 'System.Guid'}` 您必须将此属性设置为'System.Guid'}类型的非空值。
Edit: I am using Oracle.ManagedDataAccess.EntityFramework 6.121.2.0 编辑:我正在使用Oracle.ManagedDataAccess.EntityFramework 6.121.2.0
The problem is that your Oracle EF provider maps Guid
to the Raw
type, but in turn, the Raw
is mapped to a byte array. 问题是您的Oracle EF提供程序将Guid
映射到Raw
类型,但是将Raw
映射到字节数组。
You could try specifying the column type yourself, if your provider supports it (depending on your provider, it might not). 如果提供者支持,则可以尝试自己指定列类型(取决于提供者,可能不支持)。
public class Table1
{
[Column("Id", TypeName="VARCHAR(50)")]
public Guid Id { get; set; }
public string SomeOtherStuff { get; set; }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.