I am using Code First with Oracle 12c
. I have a class
public class Table1
{
public Guid Id { get; set; }
public string SomeOtherStuff { get; set; }
}
Entity Framework converts Id to 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. You must set this property to a non-null value of type 'System.Guid'}`
Edit: I am using 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.
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; }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.