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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:22:42+00:00 2026-06-04T06:22:42+00:00

I have the following simple entity: public class Something{ [DatabaseGenerated(DatabaseGeneratedOption.Computed)] public int ID {

  • 0

I have the following simple entity:

public class Something{
    [DatabaseGenerated(DatabaseGeneratedOption.Computed)]
    public int ID { get; set; }
    public string NAME { get; set; }
    public int STATUS { get; set; }
}

As you can see, I do not want the ID is generated from the database but I’m going to enter manually. This my DbContext class:

public class MyCEContext : DbContext {
    ...
    public DbSet<Something> Somethings { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder) {
        string dbsch = "myce";
        modelBuilder.Entity<Something>().ToTable("SOMETHING", dbsch);
    }
}

There is nothing special here. But this code fails:

            using (MyCEContext ctx = new MyCEContext()) {
                Something t = new Something();
                t.ID= 1;
                t.NAME = "TEST";
                t.STATUS = 100;

                ctx.Somethings.Add(t);
                ctx.SaveChanges();
            }

This is the error:

The specified value is not an instance of type ‘Edm.Decimal’

In general, allways EF try to send a value to an int primary key field, I get the edm.decimal error.

Any help?

  • 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-04T06:22:43+00:00Added an answer on June 4, 2026 at 6:22 am

    As I commented on previous answer, I’ve found better solution, it is strange, but it works

    protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
            {
                base.OnModelCreating(modelBuilder);
    
                modelBuilder.Entity<TestEntity>().ToTable("TESTENTITY", "SCHEMENAME");
                modelBuilder.Entity<TestEntity>().Property(p => p.Id).HasColumnName("ID").HasColumnType("INT");
                modelBuilder.Entity<TestEntity>().Property(p => p.TestDateTime).HasColumnName("TESTDATETIME");
                modelBuilder.Entity<TestEntity>().Property(p => p.TestFloat).HasColumnName("TESTFLOAT");
                modelBuilder.Entity<TestEntity>().Property(p => p.TestInt).HasColumnName("TESTINT");
                modelBuilder.Entity<TestEntity>().Property(p => p.TestString).HasColumnName("TESTSTRING");
            }
    

    and TestEntity looks like this

    public class TestEntity
        {
            public int Id{ get; set; }
    
            public string TestString { get; set; }
    
            public int TestInt { get; set; }
    
            public float TestFloat { get; set; }
    
            public DateTime TestDateTime { get; set; }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an entity like so: public class Land { public virtual IDictionary<string, int>
I have the following (simple) mapping: @Entity public class Role { @OneToMany( fetch =
I have following simple program: import std.stdio; int main(string[] argv) { writeln(Hello, world!); return
I have the following simple Java code: package testj; import java.util.*; public class Query<T>
I have the following entity in Hibernate: @Entity public class Contact implements Serializable {
I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,
I have the following domain class: public class Product { public virtual Guid Id
I have the following code: public abstract class RepositoryBase<T, TId> : IRepository<T, TId> where
I have the following code: public class DataReader<T> where T : class { public
I have the following simple entity: package net.plus.msodb.model; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity;

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.