Error instantiating Context with Entity Framework

3

I'm getting the Entity Framework to learn, but when I run my code, it returns the following error:

  

System.TypeLoadException: 'Inheritance security rules have been   violated by the type: 'MySql.Data.Entity.MySqlEFConfiguration'. The types   must correspond to security accessibility of the type   basis or be less accessible

Error line:

EntityContext contexto = new EntityContext();

EntityContext class:

[DbConfigurationType(typeof(MySqlEFConfiguration))]
public class EntityContext : DbContext
{
    public EntityContext() : base("MyContext")
    {

    }

    public DbSet<Usuario> Usuarios { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);
        modelBuilder.Entity<Usuario>();
    }
}

App.Config:

<connectionStrings>
  <add name="MyContext" providerName="MySql.Data.MySqlClient"
     connectionString="server=localhost;database=teste;uid=root;password="/>
</connectionStrings>

What can be happening? How to fix?

    
asked by anonymous 07.11.2017 / 00:37

0 answers