Не найдено подходящего конструктора для типа объекта - PullRequest
0 голосов
/ 02 июля 2019

У меня есть эта модель, использующая 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 Exucte ее через исключение

{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)'.

Это исключение, которое создает я передал услуги вКонструктор.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...