Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Target Project does not match your migration assembly.Please help

$
0
0

In  my project , I am keeping DbContext  in a separate project from the  web app project. This is my program structure is given below. But when I give Add-Migration the following error is coming

Your target project 'LibraryBook' doesn't match your migrations assembly 'LibraryBook.DataAccess'. Either change your target project or change your migrations assembly.
Change your migrations assembly by using DbContextOptionsBuilder. E.g. options.UseSqlServer(connection, b => b.MigrationsAssembly("LibraryBook")). By default, the migrations assembly is the assembly containing the DbContext.
Change your target project to the migrations project by using the Package Manager Console's Default project drop-down list, or by executing "dotnet ef" from the directory containing the migrations project.

LibraryBook[WebApplication]                   -> Views                  ->Appsetting.json                 ->Startup.cs
                  ->program.cs



LibraryBook.DataAccess [ another project]
            Data [folder]  -> ApplicationDbContext.cs 

Appsetting.Jason

{"ConnectionStrings": {"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=LibraryBooks;Trusted_Connection=True;MultipleActiveResultSets=true"
  },"Logging": {"LogLevel": {"Default": "Information","Microsoft": "Warning","Microsoft.Hosting.Lifetime": "Information"
    }
  },

DbConext.cs

using System;
using System.Collections.Generic;
using System.Text;
using LibraryBook.Models;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

namespace LibraryBook.DataAccess.Data
{
    public class ApplicationDbContext : IdentityDbContext
    {
        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
            : base(options)
        {
        }


Viewing all articles
Browse latest Browse all 9386

Trending Articles