public void Configure(EntityTypeBuilder <Address> builder) { builder.ToTable("Addresses", "dbo"); builder .Property(a => a.Id) .HasColumnType(MssqlTypes.INT) .ValueGeneratedOnAdd(); builder.HasKey("Id"); builder.Property(a => a.Line1).HasColumnType(MssqlTypes.NVARCHAR(512)).IsRequired(true); builder.Property(a => a.Line2).HasColumnType(MssqlTypes.NVARCHAR(512)).IsRequired(false); builder.Property(a => a.City).HasColumnType(MssqlTypes.NVARCHAR(256)).IsRequired(true); builder.Property(a => a.PostalCode).HasColumnType(MssqlTypes.NVARCHAR(16)).IsRequired(true); }
public void Configure(EntityTypeBuilder <Appointment> builder) { builder.ToTable("Appointments", "dbo"); builder.HasKey(a => a.Id); builder.Property(a => a.Id).HasColumnType(MssqlTypes.INT).ValueGeneratedOnAdd(); builder.Property(a => a.Date).HasColumnType(MssqlTypes.DATE_TIME_OFFSET).IsRequired(); builder .Property(p => p.Type) .HasColumnType(MssqlTypes.NVARCHAR(16)) .HasConversion( v => v.ToString(), v => ( AppointmentType )Enum.Parse(typeof(AppointmentType), v)); builder.Property(a => a.Diagnosis).HasColumnType(MssqlTypes.NVARCHAR()).IsRequired(); builder.HasOne(a => a.Patient).WithMany(p => p.Appointments).HasForeignKey(a => a.PatientId); }
public void Configure(EntityTypeBuilder <Patient> builder) { builder.ToTable("Patients", "dbo"); builder.HasKey(p => p.Id); builder.Property(p => p.Id).HasColumnType(MssqlTypes.NCHAR(36)).IsRequired(); builder.Property(p => p.FirstName).HasColumnType(MssqlTypes.NVARCHAR(512)).IsRequired(); builder.Property(p => p.LastName).HasColumnType(MssqlTypes.NVARCHAR(512)).IsRequired(); builder.Property(p => p.MiddleName).HasColumnType(MssqlTypes.NVARCHAR(512)).IsRequired(false); builder.Property(p => p.Phone).HasColumnType(MssqlTypes.NVARCHAR(32)).IsRequired(); builder .Property(p => p.Gender) .HasColumnType(MssqlTypes.NVARCHAR(16)) .HasConversion( v => v.ToString(), v => ( Gender )Enum.Parse(typeof(Gender), v)); builder.Property(p => p.DateOfBirth).HasColumnType(MssqlTypes.DATE).IsRequired(); builder.HasOne(p => p.Address).WithOne().HasForeignKey <Patient>(); builder.HasMany(p => p.Appointments).WithOne(a => a.Patient); }