HI我在尝试将数据保存到表格[ir]时出错。[InspectionQCExceptionRuleConfig]
{"指定的参数超出了有效范围 值。\ r \ n参数名称:名称"}
我不知道为什么,我正在尝试保存数据。但是,我能够从模型中检索数据。我粘贴了代码,上下文和域模型。如果有人知道他的。请告诉我..
public InspectionQCExceptionRuleConfig SaveInspectionQCRules
(InspectionQCExceptionRuleConfig inspectionruleconfig)
{
if (inspectionruleconfig != null)
{
try
{
using (InspRulesData ctx = new InspRulesData())
{
inspectionruleconfig = ctx.UpdateGraph(inspectionruleconfig, map => map);
//ctx.InspectionQCExceptionRuleConfigs.Add(inspectionruleconfig);
ctx.SaveChanges();
}
}
catch (DbEntityValidationException ex)
{
Logging.LogError(ex);
throw;
}
catch (Exception ex)
{
Logging.LogError(ex);
throw;
}
}
return inspectionruleconfig;
}
这是从Entity Framework
生成的域模型 namespace DomainModel.FSEntity.InspRules
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;
using CommonLib;
[System.CodeDom.Compiler.GeneratedCode("EF", "6.1.0")]
[Table("ir.InspectionQCExceptionRuleConfig")]
public partial class InspectionQCExceptionRuleConfig : BaseDomainModel
{
[Key]
[StringLength(50)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public string ClientNumber { get; set; }
public bool QCOrdered { get; set; }
public bool DwellingType { get; set; }
public bool VacantToOccupied { get; set; }
public bool VacantToOccupiedWithActivePreservation { get; set; }
}
}
这是实体框架用于保存表中的数据的上下文InspectionQCExceptionRuleConfig
public partial class InspRulesData : CustomDbContext
{
public InspRulesData()
: base("name=PlatformEntityData")
{
this.Configuration.LazyLoadingEnabled = false;
}
public virtual DbSet<InspectionQCExceptionRuleConfig> InspectionQCExceptionRuleConfigs { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<InspectionQCExceptionRuleConfig>()
.Property(e => e.ClientNumber)
.IsVariableLength()
.IsUnicode(false);
}
}
答案 0 :(得分:0)
它也可能是由域模型中错误放置的[NotMapped]属性引起的。