Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiled model has invalid using directive when model is not in a namespace #25058

Closed
ajcvickers opened this issue Jun 8, 2021 · 0 comments · Fixed by #25584
Closed

Compiled model has invalid using directive when model is not in a namespace #25058

ajcvickers opened this issue Jun 8, 2021 · 0 comments · Fixed by #25584
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@ajcvickers
Copy link
Member

Generated code:

// <auto-generated />
using ;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;

// ...

Repro:

public class Blog
{
    public int Id { get; set; }
}

public class SomeDbContext : DbContext
{
    private static ILoggerFactory ContextLoggerFactory
        => LoggerFactory.Create(b => b.AddConsole().SetMinimumLevel(LogLevel.Information));

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder
            .UseSqlServer(Your.ConnectionString)
            .UseLoggerFactory(ContextLoggerFactory)
            .EnableSensitiveDataLogging();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Blog>();
    }
}

public class Program
{
    public static void Main()
    {
        using (var context = new SomeDbContext())
        {
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();
        }
    }
}
@ajcvickers ajcvickers transferred this issue from dotnet/EntityFramework.Docs Jun 8, 2021
@AndriySvyryd AndriySvyryd self-assigned this Jun 9, 2021
@AndriySvyryd AndriySvyryd added this to the 6.0.0 milestone Jun 11, 2021
AndriySvyryd added a commit that referenced this issue Aug 19, 2021
…iledModels

Handle context types in the global namespace

Fixes #25058
Fixes #25059
@AndriySvyryd AndriySvyryd added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Aug 19, 2021
@AndriySvyryd AndriySvyryd modified the milestones: 6.0.0, 6.0.0-rc2 Aug 19, 2021
@AndriySvyryd AndriySvyryd removed their assignment Aug 19, 2021
AndriySvyryd added a commit that referenced this issue Aug 19, 2021
…iledModels

Handle context types in the global namespace

Fixes #25058
Fixes #25059
AndriySvyryd added a commit that referenced this issue Aug 19, 2021
…iledModels

Handle context types in the global namespace

Fixes #25058
Fixes #25059
AndriySvyryd added a commit that referenced this issue Aug 19, 2021
…iledModels

Handle context types in the global namespace

Fixes #25058
Fixes #25059
@ajcvickers ajcvickers modified the milestones: 6.0.0-rc2, 6.0.0 Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-model-building closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants