EntityFramework代码首先一对多

时间:2018-07-09 15:14:16

标签: asp.net model-view-controller

我想问你如何用这段代码创建EntityFramework关系一对多?

我需要建立联系,一家公司可以拥有许多用户。有了下面显示的代码

using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;

namespace Ideo.Mvc.Data.Model.Core
{
public class FirmyValue : Entity
{
    public string Nazwa { get; set; }
    public string NIP { get; set; }
    public string Adres { get; set; }
}

internal class FirmyValueMappings : EntityTypeConfiguration<FirmyValue>
{
    public FirmyValueMappings()
    {
        Property(p => p.Nazwa).HasMaxLength(200);
        Property(p => p.NIP).HasMaxLength(200);
        Property(p => p.Adres).HasMaxLength(200);
    }
}
}

0 个答案:

没有答案