efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Inheritance of DBContext, error writing, causes visual studio compilation to generate errors too much

Open leehavin opened this issue 9 years ago • 4 comments

After inheriting the DbContext, add the constructor, and I know it's not right to add this.But the compiled error message can cause a lot of 421 errors. The added code is as follows: public UmsContext(DbContextOptions options) : base(options) {}

Exception message: image Code:

    public class UmsContext : DbContext
    {
        public UmsContext(DbContextOptions options) : base(options)
        {
        }

        public int TenantId { get; set; }

        public DbSet<UserEntity> User { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            var config = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json")
                .Build();
            
            // define the database to use
            optionsBuilder.UseSqlServer(config.GetConnectionString("DefaultConnection"));
           
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.AddEntityConfigurationsFromAssembly(GetType().Assembly);
        }
    }

Further technical details

EF Core version: (found in project.csproj or packages.config) Database Provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer) Operating system: IDE: (e.g. Visual Studio 2017 15.3.1)

leehavin avatar Aug 20 '17 06:08 leehavin

None of the error in screenshot indicates there is error in EF Core code or C# code either. Like the first 4 errors in the image is showing incorrect JS file. Please find details of any EF related compilation error if any.

smitpatel avatar Aug 20 '17 14:08 smitpatel

@smitpatel The error reported was index.d.s and nodejs, but they were not used in the project.When I add it ”public UmsContext(DbContextOptions options):base(options){}“ error。 Get rid of all normal

leehavin avatar Aug 21 '17 02:08 leehavin

@leehavin - Share repro code which demonstrate what you are seeing. Again there is no visible C# error here.

smitpatel avatar Aug 22 '17 17:08 smitpatel

EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it.

BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.

ajcvickers avatar Aug 30 '17 18:08 ajcvickers