Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Add-Migration após completar os dados do Pedido (Nome, endereco, etc)

    public class Pedido : BaseModel
    {
        public List<ItemPedido> Itens { get; private set; }

        public Pedido()
        {
            Itens = new List<ItemPedido>();

            Nome = "Alura da silva";
            Email = "alura@alura.com.br";
            Endereco = "Rua Vergueiro, 3185";
            Bairro = "Vila Mariana";
            Municipio = "São Paulo";
        }

        public string Nome { get; private set; }
        public string Email { get; private set; }
        public string Telefone { get; private set; }
        public string Endereco { get; private set; }
        public string Complemento { get; private set; }
        public string Bairro { get; private set; }
        public string Municipio { get; private set; }
        public string UF { get; private set; }
        public string CEP { get; private set; }
    }
PM> Add-Migration Cadastro
Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\Fabio\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
An error occurred while calling method 'BuildWebHost' on class 'Program'. Continuing without the application service provider. Error: Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting to activate 'CasaDoCodigo.DataService'.
Unable to create an object of type 'Contexto'. Add an implementation of 'IDesignTimeDbContextFactory<Contexto>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.
PM>
1 resposta
solução!

Olá Fabio,

na sua classe Startup, no começo do método ConfigureServices, adiciona este comando e veja se resolve o problema:

services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software