RAHUL GIRI
RAHUL GIRI

Reputation: 1

Getting error while using Add-Migration Initial

I have been trying to use code first approach to create a database via already written models and context class. Below is my context class for reference.

using BankLibrary.Models;
using Microsoft.EntityFrameworkCore;

public class BankDBContext : DbContext
{
public BankDBContext()
{
}

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

public DbSet<AccountHolderDetails> AccountDetails { get; set; }
public DbSet<TransactionDetails> TransactionDetails { get; set; }
public DbSet<LoanDetails> LoanDetails { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
   optionsBuilder.UseSqlServer("data source=(localdb)\\MSSQLLocalDB; database=BankDB;    integrated security=true");
}

}

But I have been getting the error: enter image description here

I don't know how to resolve it. I could not find any solution online. I have used this same code before for other projects but this time, I am getting the above error. Can anyone please help me with this?

I have already tried changes suggested by ChatGPT and reinstalled the packages (Microsoft.EntityFrameworkCore.Tools and Microsoft.EntityFrameworkCore.SqlServer) as instructed. Still did not resolve the error.

Upvotes: 0

Views: 19

Answers (0)

Related Questions