I'm developing an application using DDD architecture. In my Infra layer, I have my data models, all based on Code First . I am using SQL as the database. I already installed everything that was needed.
It turns out that when I try to apply Migration I get the error:
PM> Add-Migration -MuoContext Initial
Add-Migration : Não é possível localizar um parâmetro que coincida com o nome de parâmetro 'MuoContext'.
No linha:1 caractere:15
+ Add-Migration -MuoContext Initial
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Add-Migration], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Add-Migration
The MuoContext parameter is the name of my class, as can be seen below:
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Muo.Domain.Areas.BI.Entities;
using Muo.Domain.Areas.Commons.Entities;
using Muo.Infrastructure.Data.Mappings.Areas.BI;
using Muo.Infrastructure.Data.Mappings.Areas.Commons;
using System;
using System.IO;
using System.Linq;
namespace Muo.Infrastructure.Data.Context
{
public class MuoContext : DbContext
{
#region DbSets
//DbSets - ../Domain/Areas/Commons/Entities
public DbSet<CnaeActivity> CnaeActivities { get; set; }
public DbSet<Company> Companies { get; set; }
public DbSet<CompanyAddress> CompanyAddresses { get; set; }
//DbSets - ../Domain/Areas/BI/Entities
public DbSet<ChartOfAccountStandardDfp> ChartOfAccountStandardDfps { get; set; }
#endregion
#region Configurations
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
//Mappings/Areas/BI
modelBuilder.ApplyConfiguration(new ChartOfAccountStandardDfpMap());
//Mappings/Areas/Commons
modelBuilder.ApplyConfiguration(new CompanyMap());
modelBuilder.ApplyConfiguration(new CompanyAddressMap());
modelBuilder.ApplyConfiguration(new CnaeActivityMap());
base.OnModelCreating(modelBuilder);
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
optionsBuilder.UseSqlServer(config.GetConnectionString("DefaultConnection"));
}
My gadget appsettings.json looks like this:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(LocalDb)\MSSQLLocalDB;Database=MuoDB;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
I do not understand and I can not find a solution.