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 8685153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:29:30+00:00 2026-06-12T22:29:30+00:00

I have the following table: create table tbl ( id int identity(1,1), val varchar(100)

  • 0

I have the following table:

create table tbl
(
    id int identity(1,1),
    val varchar(100)
)

Now when i use Entity Framework to map objects to this table, it works, however when i change the table definition as follows:

create table tbl1
(
    id int,
    val varchar(100)
)

Entity Framework does not maps objects to this table. Any clue as to why is this happening would be appreciated.

  • 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-12T22:29:32+00:00Added an answer on June 12, 2026 at 10:29 pm

    Entity Framework requires a Primary Key to generate a model from the database. If there is no Primary Key on a table it will simply select the non-nullable columns as a concatenated primary key and the Entity will be read/only.

    In your first table identity definition makes your id column non-nullable so you were able to create an Entity. You should have seen this message while adding that table:

    “The table/view ‘tbl1’ does not have a primary key defined. The key
    has been inferred and the definition was created as a read-only
    table/view.”

    In your second table however there is no non-nullable column and EF cannot create an Entity for it. See the message when you try to add it:

    “The table/view ‘tbl1’ does not have a primary key defined and no
    valid primary key could be inferred. This table/view has been
    excluded. To use the entity, you will need to review your schema, add
    the correct keys, and uncomment it.”

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

Sidebar

Related Questions

I have the following table: create table ARDebitDetail(ID_ARDebitDetail int identity, ID_Hearing int, ID_AdvancedRatePlan int)
I have the following table: CREATE TABLE [dbo].[Tree]( [AutoID] [int] IDENTITY(1,1) NOT NULL, [Category]
I have the following table CREATE TABLE [dbo].[LogFiles_Warehouse]( [id] [int] IDENTITY(1,1) NOT NULL, [timestamp]
Say, if I have the following table: CREATE TABLE tbl (ID INT, Type UNIQUEIDENTIFIER)
I have the following table: CREATE TABLE [dbo].[EntityAttributeRelship]( [IdNmb] [int] IDENTITY(1,1) NOT NULL, [EntityIdNmb]
I have the following table: CREATE TABLE [dbo].[omgbbq]( [tbl_key] [int] IDENTITY(1,1) NOT NULL, [name]
I have the following table in SQL Server 2008: CREATE TABLE tbl (ID INT,
I have the following table CREATE TABLE `prod_prices` ( `id` varchar(32) COLLATE utf8_unicode_ci NOT
I have the following table: CREATE TABLE IF NOT EXISTS `customer_list` ( `id` INT
Let's say we have the following table: CREATE TABLE T ( ID INT, String1

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.