.NET Fiddle

CSharp · Console

/Program.cs

using System.Data.Entity;
using System.Linq;

public class Initializer : DropCreateDatabaseAlways<FooContext>
{
    protected override void Seed(FooContext context)
    {
        context.Foos.AddRange(Enumerable.Range(0, 1000)
            .Select(i => new Foo { IsActive = i % 3 == 0 }));

        context.Database.ExecuteSqlCommand("CREATE INDEX IX_Foo_IsActive ON Foos (IsActive) WHERE (IsActive = 0)");
    }
}

public class Foo
{
    public int Id { get; set; }
    public bool IsActive { get; set; }
}

public class FooContext : DbContext
{
    public FooContext()
    {
        Database.SetInitializer(new Initializer());
    }

    public DbSet<Foo> Foos { get; set; }
}

public static class Program
{
    public static void Main()
    {
        using (FooContext context = new FooContext())
        {
            context.Foos.Count(f => !f.IsActive);
        }
    }
}
;