Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8364811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:31:03+00:00 2026-06-09T12:31:03+00:00

Using asp.NET MVC3, I am creating trying to create an abstract class/model with the

  • 0

Using asp.NET MVC3, I am creating trying to create an abstract class/model with the following:

namespace core.Models.Concrete
{
  public class item
  {
    [Key]
    public Guid id { get; set; }
    public Type ConcreteType { get; set; }
    public itemtype Type { get; set; }
    public string barcode { get; set; }
    public int rating { get; set; }
    public string Title { get; set; }
  }
}


public enum itemtype 
{
  Game,
  Book,
  Film
}

Which is used by:

namespace core.Models.Abstract
{
  public class game : item
  {
    public gamePlatform platform { get; set; }
  }



  public enum gamePlatform
  {
    PC,
    X360,
    PS3,
    Wii
  }
}

When I run the update-database in Entity Framework 4.3 code first migrations I get:

Value cannot be null.
Parameter name: key

Am I doing something wrong? Is this even an accepted way of doing things.I don’t really want to use an interface as this would mean implementing all the fields in each thing that uses item

EDIT
I have just found that this comes from the following code in global.asax.cs in Application_Start:

protected void Application_Start()
    {
      AreaRegistration.RegisterAllAreas();

      RegisterGlobalFilters(GlobalFilters.Filters);
      RegisterRoutes(RouteTable.Routes);

      //System.Data.Entity.Database.SetInitializer<DataContext>(new DataContextInitializer());

      using (coreContext TestContext = new coreContext())
      {
        var x =TestContext.Users.Count();  <!-- THIS LINE HERE
        try
        {
          Roles.CreateRole("User");
        }catch
        {
          //Already created
        }
      }

    }

Core COntext:

public class coreContext : DbContext
    {
 public DbSet<core.Models.Abstract.game> games { get; set; }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:31:04+00:00Added an answer on June 9, 2026 at 12:31 pm

    Your error is coming from public Type ConcreteType, are you missing a class definition? Type normally refers to System.Type is that what you’re actually wanting to put in your class? EF has no way to translate that into a SQL type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an ASP.NET MVC3 application using NHIBERNATE. I have a base class
In ASP.NET MVC3, when a view model is passed into a view using return
I have an employee class in model for ASP.NET MVC3. There is a field
I am creating a new web application using ASP.NET MVC3 Razor and HTML 5.
Currently, I am creating an application using ASP.NET MVC3 and MySQL and when I
Using ASP.Net MVC3 with C#. Currently I am trying to pass a single database
Using ASP.net MVC3 with C# I want to create a partial view that uses
I am creating my first ASP.Net MVC3 Application using Azure as DB Storage. There
I'm creating an MVC3 asp.net application using Entity Framework 4 and C#. I've tried
I am using Asp.Net MVC3, for a project. In one of the page, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.