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 –