2
I’m trying to make my code run, but I’m not getting it because of this Error
Severity Code Description Project File Line Error CS0311 The type 'Controleinterno.Migrations.Controleinterno.Controleintcontexto' cannot be used as type Parameter 'Tcontext' in the Generic type or method 'Dbmigrationsconfiguration'. There is no implicit Reference Conversion from 'Controleinterno.Migrations.Controleinterno.Controleintcontexto' to 'System.Data.Entity.Dbcontext'. Controleinterno F: Documents Visual Studio 2015 Projects Internal Control Controleinterno Migrations Configuration.Cs 6
using ControleInterno.Model;
using System.Data.Entity;
namespace ControleInterno
{
class ControleIntContexto : DbContext
{
public ControleIntContexto()
{
Configuration.LazyLoadingEnabled = false;
}
public DbSet<Produto> Produtos { get; set; }
}
}
Follow the code from the Configuration.Cs file
namespace ControleInterno.Migrations
{
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
internal sealed class Configuration : DbMigrationsConfiguration<ControleInterno.ControleIntContexto>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
}
protected override void Seed(ControleInterno.ControleIntContexto context)
{
// This method will be called after migrating to the latest version.
// You can use the DbSet<T>.AddOrUpdate() helper extension method
// to avoid creating duplicate seed data. E.g.
//
// context.People.AddOrUpdate(
// p => p.FullName,
// new Person { FullName = "Andrew Peters" },
// new Person { FullName = "Brice Lambson" },
// new Person { FullName = "Rowan Miller" }
// );
//
}
}
}
I don’t understand why he doesn’t recognize my kind of context...
– Iago Frota
Place the code of your context class
– Jéf Bueno
I used this tip [http://stackoverflow.com/questions/11918401/enable-migrations-error-project-failed-to-build] and it worked. I wonder what the effects of that are?
– Iago Frota
Also enter the code of the configuration class you deleted. The explanation is in it.
– Leonel Sanches da Silva