C
C#3y 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);
}
}
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);
}
}
No description
3 Replies
Tvde1
Tvde13y ago
Have you tried to clean & rebuild your solution?
ergazia
ergazia3y ago
Install (or update) NuGet package Microsoft.CodeAnalysis.CSharp.Workspaces version 2.0.0 or higher And then retry to scaffolding again
Pandetthe
PandettheOP3y ago
Thx that helped
Want results from more Discord servers?
Add your server