相关疑难解决方法(0)

EF 5 Model First Partial Class Custom Constructor如何?

EF已经为我生成了一些部分类,每个都有一个构造函数,但它表示不要触摸它们(下面的示例),现在如果我创建自己的辅助部分类并且我想要一个构造函数自动设置一些字段如何我会这样做,因为它会发生冲突吗?

//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Breakdown.Models
{
    using System;
    using System.Collections.Generic;

    public partial class Call
    {
        public Call()
        {
            this.Logs = new HashSet<Log>();
        }

        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

constructor entity-framework partial-classes ef-model-first

10
推荐指数
2
解决办法
3805
查看次数