![](/img/trans.png)
[英]could not be set to a 'System.Decimal' value. You must set this property to a non-null value of type 'System.Double'
[英]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'
我在Oracle 12c
使用Code First。 我有一堂課
public class Table1
{
public Guid Id { get; set; }
public string SomeOtherStuff { get; set; }
}
實體框架將ID轉換為RAW
CREATE TABLE "FB"."Media"
( "Id" RAW(16) NOT NULL ENABLE, ...
所以現在如果我這樣做:
var list = db.Table1.SqlQuery("select * from Table1")).ToList();
我得到一個錯誤
無法將“表1”上的“ Id”屬性設置為“ System.Byte []”值。 您必須將此屬性設置為'System.Guid'}類型的非空值。
編輯:我正在使用Oracle.ManagedDataAccess.EntityFramework 6.121.2.0
問題是您的Oracle EF提供程序將Guid
映射到Raw
類型,但是將Raw
映射到字節數組。
如果提供者支持,則可以嘗試自己指定列類型(取決於提供者,可能不支持)。
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.