我使用EntityFrameworkCore拥有此模型
public class SafetyVisitModel : BaseModel
{
ISafetyVisitService _safetyService;
IModuleService _moduleService;
IDepartmentService _departmentService;
[PreferredConstructorAttribute]
public SafetyVisitModel(ISafetyVisitService safetyService = null, IModuleService moduleService = null, IDepartmentService departmentService = null)
{
_safetyService = safetyService;
_moduleService = moduleService;
_departmentService = departmentService;
}
SafetyVisitModel() { }
//public int _id { get; set; }
private int _id = 0;
//[AutoIncrement, PrimaryKey]
public int _ID { get { return _id; } set { _id = value; RaisePropertyChanged(() => _ID); } }
private Guid _UniqueID = Guid.NewGuid();
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid UniqueID { get { return _UniqueID; } set { if (value != null) _UniqueID = value; RaisePropertyChanged(() => UniqueID); } }
private int _SharepointID = 0;
public int ID { get { return _SharepointID; } set { _SharepointID = value; RaisePropertyChanged(() => ID); } }
private string _VisitedLocation = string.Empty;
public string VisitedLocation { get { return _VisitedLocation; } set { _VisitedLocation = value; /*RaisePropertyChanged(() => VisitedLocation);*/ } }
private string _VisitedDepartment = string.Empty;
public string VisitedDepartment { get { return _VisitedDepartment; } set { _VisitedDepartment = value; /*RaisePropertyChanged(() => VisitedDepartment);*/ } }
private string _VisitedSgid = string.Empty;
public string VisitedSgid { get { return _VisitedSgid; } set { _VisitedSgid = value; /*RaisePropertyChanged
(() => VisitedSgid);*/ } }
还有任务功能 以及Dbsets通过异常触发
{System.InvalidOperationException: No suitable constructor found for entity type 'XName'. The following constructors had parameters that could not be bound to properties of the entity type: cannot bind 'ns', 'localName' in 'XName(XNamespace ns, string localName)'.
这是正在产生的异常,我已经在Constructor中传递了服务。