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

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

Closed
balachir opened this issue May 22, 2015 · 1 comment
Closed
Labels

Comments

@balachir
Copy link

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

@rowanmiller
Copy link
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.

@bricelam bricelam modified the milestone: 7.0.0 Dec 10, 2015
@bricelam bricelam removed their assignment Dec 10, 2015
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants