C
Join ServerC#
help
Problem with creating controller based on EF Core
PPandetthe8/11/2022
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);
}
}

TTvde18/11/2022
Have you tried to clean & rebuild your solution?
EErgazia8/11/2022
Install (or update) NuGet package Microsoft.CodeAnalysis.CSharp.Workspaces version 2.0.0 or higher
And then retry to scaffolding again
PPandetthe8/11/2022
Thx that helped