Emanuele Leoni

Emanuele Leoni

  • NA
  • 139
  • 16k

default DbConfiguration instance was used by EntityFramework

Mar 19 2018 4:16 AM
I have a DAL project with this ApplicationContext.cs
  1. [DbConfigurationType(typeof(MyConfiguration))] 
  2. public class ApplicationDbContext : IdentityDbContext<ApplicationUser> 
  3. public ApplicationDbContext() : base("DefaultConnection", throwIfV1Schema: false) { } ... 
  4. }  
but when I instance it in an other project
  1. using (var databaseContext = new ApplicationDbContext()) { }  
I get this error:
 
The default DbConfiguration instance was used by the Entity Framework before the 'MyConfiguration' type was discovered. An instance of 'MyConfiguration' must be set at application start before using any Entity Framework features or must be registered in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=260883 for more information.
 
I tried to solve it updating the web.config file, inserting codeConfigurationType in node, but I get the same error.
 
Can anyone help me?

Answers (6)