I am working on WCF .NET Framework 4.8 project and its WCF is self-hosted in a Console application.
I have set up the defined POCO classes and DbContext in their own separate project that is referenced by the WCF console app.
I have declared the Connection String for the DbContext in the app.config within the main console app.
When I try to execute the EF Code First commands like EnableMigrations and Add-Migration they fail to execute with the error:
No context type was found in the assembly 'MAL.App.ConsoleHost'
console application App.Config
<entityFramework>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
<connectionStrings>
<add name="AppDbContext" connectionString="Data Source=MySQLEXPRESS;Initial Catalog=MyDB;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
Data Class Library
public class AppDbContext: DbContext
{
public DbSet<Album> Albums { get; set; }
public DbSet<AlbumType> AlbumTypes { get; set; }
public DbSet<Artist> Artists { get; set; }
}
One POCO class
public class Album
{
public Guid AlbumID { get; set; }
public string AlbumName { get; set; }
public Guid ArtistID { get; set; }
public Guid AlbumTypeID { get; set; }
public int Stock { get; set; }
public Artist Artist { get; set; }
public AlbumType AlbumType { get; set; }
}
Console Main Program
static void Main(string[] args)
{
ServiceHost hostMusicService = new ServiceHost(typeof(MyWebServices));
hostMusicService.Open();
Console.WriteLine("Web Services Started. Press [Enter] To Exit ");
Console.ReadLine();
hostMusicService.Close();
}

