是否可以使用(awesome)EntityFramework Reverse POCO Generator在table-per-type繼承方案中生成POCO?使用實體框架的每種類型表繼承反向POCO生成器
我的數據庫包含一個「基地」日誌表中,兩個表,從它派生:
create table LogBase
(
Id int identity(1, 1) not null,
LogTime datetime not null default getdate(),
constraint PK_LogBase primary key clustered(Id)
)
create table ErrorLog
(
Id int not null,
ErrorMessage nvarchar(max),
StackTrace nvarchar(max),
constraint PK_ErrorLog primary key(Id),
constraint FK_ErrorLog_LogBase foreign key(Id) references LogBase(Id)
)
create table ChangeLog
(
Id int not null,
PropertyName nvarchar(max),
OldValue nvarchar(max),
NewValue nvarchar(max),
constraint PK_ChangeLog primary key(Id),
constraint FK_ChangeLog_LogBase foreign key(Id) references LogBase(Id)
)
默認情況下,反向POCO產生器產生3 C#類 - LogBase,錯誤日誌,並修改記錄 - 每個其中包含Id
屬性,並且它們之間沒有繼承關係。
我可以指定錯誤日誌和更新日誌通過創建類的泛音和把: LogBase
繼承的部分類從LogBase繼承 - 這是指定的繼承的正確方法?
在模板生成器中,UpdateColumn
回調允許我指定在生成的POCO中應該省略其Id
列的表。
我可以使用UpdateColumn
作爲ErrorLog和ChangeLog表 - 這會導致從每個類中刪除'Id'屬性,這對於每種類型的繼承是正確的。然而,這也導致在錯誤日誌和更新日誌類從生成的DbContext被刪除,下面註釋出現在錯誤日誌和更新日誌類:
// The table 'ChangeLog' is not usable by entity framework because it
// does not have a primary key. It is listed here for completeness.
是否有指定的繼承關係沒有辦法 導致生成器忽略模型中的派生表?
有沒有辦法阻止生成器在生成的POCO中包含導航 屬性?
大指針使用UpdateColumn來解決重複ID問題TPT。謝謝。 –