C#C
C#4y ago
Pandetthe

Problem with creating controller based on EF Core

Hi, I've got this error when I tried to create controller based on model
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace CafeApp.Models
{
    public partial class CafeDbContext : DbContext
    {
        public CafeDbContext()
        {
        }

        public CafeDbContext(DbContextOptions<CafeDbContext> options)
            : base(options)
        {
        }

        public virtual DbSet<CustomerInfo> CustomerInfos { get; set; } = null!;

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<CustomerInfo>(entity =>
            {
                entity.ToTable("CustomerInfo");

                entity.Property(e => e.Id)
                    .HasMaxLength(10)
                    .IsFixedLength();

                entity.Property(e => e.Email)
                    .HasMaxLength(507)
                    .IsFixedLength();

                entity.Property(e => e.Name)
                    .HasMaxLength(256)
                    .IsFixedLength();
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
unknown.png
Was this page helpful?