Skip to content

Add ef migration for a conext without namespace, we get ArgumentNullException  #2261

Closed as not planned

Description

@balachir

Using Dev14 RC (beta4)

  1. New Empty Web API app : AspNet5BookService
  2. Add class Author.cs to Models folder
namespace AspNet5BookService.Models
{
    public class Author
    {
        public int Id { get; set; }
        [Required]
        public string Name { get; set; }
    }
}

3, Add BookServiceContext.cs class to Models folder - but forgot to set the namespace

using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Metadata;

    public class BookServiceContext : DbContext
    {
        private static bool _created = false;

        public DbSet<Author> Authors { get; set; }

        public DbSet<Book> Books { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=BookServiceContext;Trusted_Connection=True;MultipleActiveResultSets=true");
        }

        protected override void OnModelCreating(ModelBuilder builder)
        {
        }
    }

4, Add EF migration

ACTUAL
Exception below. It took a little while to figure out that missing namespace was the issue

image

Activity

  1. added this to the 7.0.0 milestone on May 27, 2015
  2. rowanmiller commented on Dec 3, 2015

    @rowanmiller
    Contributor

    This is no longer an issue as of RC1. You do still get an invalid using (tracked by #2467), but the migration is scaffolded.

  3. modified the milestone: 7.0.0 on Dec 10, 2015
  4. removed their assignment
    on Dec 10, 2015
  5. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions