Doubt with EntityFramework (Migration)

2

I'm trying to get my code to run, but I'm not getting through this Error

  

Severity Code Description Project File Line   Error CS0311 The type 'InternalControl.Migrations.InternalControl.IntContext' can not be used as the 'TContext' type parameter in the generic type or method 'DbMigrationsConfiguration'. There is no implicit reference conversion from 'InternalControl.Migrations.InternalControl.ControlIntContext' to 'System.Data.Entity.DbContext'. F: \ Documents and Settings \ Visual Studio 2015 \ Projects \ Internal Control \ Internal Control \ 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 in 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" }
            //    );
            //
        }
    }
}
    
asked by anonymous 30.09.2015 / 02:44

1 answer

1

This here was generating naming ambiguity:

namespace ControleInterno
{
    class ControleIntContexto : DbContext
    { ... }
}

As you have removed the correct namespace context from it ( ControleInterno.Models ), note that the compiler resolved the context name as follows:

ControleInterno.Migrations.ControleInterno.ControleIntContexto

And that obviously is wrong.

Just change the namespace of the context and fix the references that work again.

    
02.10.2015 / 06:13