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

  • Home
  • SEARCH
  • 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 6646029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:21:58+00:00 2026-05-26T00:21:58+00:00

One or more validation errors were detected during model generation: System.Data.Edm.EdmEntityType: : EntityType ‘Person’

  • 0

One or more validation errors were detected during model generation:

System.Data.Edm.EdmEntityType: : EntityType 'Person' has no key defined. Define the key for this EntityType.
System.Data.Edm.EdmEntitySet: EntityType: The EntitySet People is based on type Person that has no keys defined.

—> Person.cs ( in models )

 using System;
   using System.Collections.Generic;
   using System.Linq;
   using System.Web;
   using System.ComponentModel.DataAnnotations;

   namespace Portal.Models
    {
    public class Person
        {
            [Required]
            public int UserId;

            [Required]
            public string FirstName;

        [Required]
        public string LastName;

        }
    }

— > PersonDB.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;

namespace Portal.Models
{

    public class PersonDB : DbContext
    {
        public DbSet<Person> Person { get; set; }
    }
}

— > web.config connectionstring.

  <connectionStrings>

    <add name="ApplicationServices"
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|ASPNETDB.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />

      <add name="PersonDB"
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|ASPNETDB.mdf;User Instance=true"
         providerName="System.Data.SqlClient" />

  </connectionStrings>

— > AccountController ( trying to add values if account creation succeded )

 PersonDB db = new PersonDB();
                    Person p = new Person {UserId = 1, FirstName = "hej", LastName = "padig"};
                    db.Person.Add(p);
                    db.SaveChanges();

Here I’m just trying to add some test values to the table, the table consists of UserId with is int, and nvarchar FirstName, LastName.

Where does this People come from in the validation error?
“The EntitySet People is based on type Person” << This is driving me insane.

Don’t get this, I’ve spent way too much time with this which essentially just is an insert into query…

  • 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-05-26T00:21:59+00:00Added an answer on May 26, 2026 at 12:21 am

    First, every entity type needs a key. If you got the property named Id or 'EntityClassName'Id, it is chosen as the key by default (that’s the convention in other words). As you do not have property named Id or PersonId – you’ve got only UserId, you get first validation error that Person has got no key. Add the [Key] attribute on UserId, or use the fluent interface code

    //Inside PersonDB class
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
    
            modelBuilder.Entity<Person>().HasKey(x => x.UserId);
        }
    

    PluralizingEntitySetNameConvention is one more example of conventions. Entity Framework uses this convention by default and makes entity set names plural. If you do not wish to use this convention, you can remove it. Here is the list of all the default conventions. You can remove undesired convention by calling

    //Inside PersonDB class
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
    
            modelBuilder.Entity<User>().HasKey(x => x.UserId);
    
    ....
    
            modelBuilder.Conventions.Remove<ConventionTypeNameFromTheLinkAbove>();
        }
    

    If you look carefull, you can see that KeyAttributeConvention is also one of default builtin conventions.

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

Sidebar

Related Questions

I have a trouble as description below: One or more validation errors were detected
I'm looking to make validation for a page in which one or more fields
One more question about most elegant and simple implementation of element combinations in F#.
Is one more preferred, or performs better over the other?
Here one more basic question asked in MS interview recently class A { public
Here is one more newbie question: require 'tasks/rails' I saw this line in Rakefile
UPDATED: Added one more question (Question #4). Hi all, I'm building myself a custom
Now I'm following one more friend and now I started to learn PLT Scheme(using
Hey guys I have one more question lol. I am using a script that
How to make one more eval merge ? <asp:HiddenField ID=HiddenField1 runat=server Value='<%# Eval(Name),Eval(Surname),Eval(Mail)%>'/>

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.