0
在在SQL Server中的表由我是否可以用非抽象基類將EF代碼第一個TPH?
CREATE TABLE [dbo].[ReportDataV2](
[ID] [int] IDENTITY(1,1) NOT NULL,
[DataTypeName] [nvarchar](max) NULL,
[IsInplaceReport] [bit] NOT NULL,
[PredefinedReportTypeName] [nvarchar](max) NULL,
[Content] [varbinary](max) NULL,
[DisplayName] [nvarchar](max) NULL,
[ParametersObjectTypeName] [nvarchar](max) NULL,
CONSTRAINT [PK_dbo.ReportDataV2] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
這恰好是開發快速XAF報告表中定義。
在我的數據方面,我有
public DbSet<ReportDataV2> ReportDataV2 { get; set; }
我希望能夠治療DataTypeName字段作爲鑑別列而不ReportDataV2已經工作在我的代碼的方式干擾。
我嘗試了以下,但實體框架檢測到數據結構已更改,如果我生成遷移,我看到它正在嘗試重新創建ReportDataV2表。
public class OrderCountReport2Configuration : EntityTypeConfiguration<ReportDataV2>
{
public OrderCountReportConfiguration()
: base()
{
ToTable("ReportDataV2", "dbo");
HasKey(tp => tp.ID);
Map<OrderCountReport>(m => m.Requires("DataTypeName").HasValue("OrderCountReport"));
}
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new OrderCountReportConfiguration());
base.OnModelCreating(modelBuilder);
}
}
我想我的問題可能是我想用一列類型爲nvarchar(最大)的鑑別柱。 如果我運行遷移生成的代碼具有字段長度4000 –
http://stackoverflow.com/questions/5053335/entity-framework-ctp5-code-first-how-do-i-specify-the-type-的最discrimimator –