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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:35:38+00:00 2026-06-01T09:35:38+00:00

I’m in Asp.net MVC3 environment, and I use Advantage Database 9.1. and I want

  • 0

I’m in Asp.net MVC3 environment, and I use Advantage Database 9.1.

and I want to get the Advantage Database data in Asp.net (+Repository pattern)

My Advantage Database has WebOrderHd table and I want to get the PK field of the table and count it.

(Table Name : WebOrderHd Field Name : PK (character(36))

I think I connect to DB server successfully but I can not get the data.

here is my codes,

Web.config

<add name="EFAdsContext" connectionString="Data Source=\\XXX.XX.XX.XX:6262\DB_BACK\SD.ADD;ServerType=REMOTE;User ID=AdsSys;Password=xxxxx"
         providerName="Advantage.Data.Provider" />

/Concrete/EFAdsContext.cs

public class EFAdsContext : DbContext
{
    public DbSet<WebOrderHd> weborderhd { get; set; }
}

/Concrete/EFWebOrderHdRepository.cs

public class EFWebOrderHdRepository : IWebOrderHdRepository
{
    private EFAdsContext context = new EFAdsContext();

    public IQueryable<WebOrderHd> WebOrderHd
    {
        get { return context.weborderhd; }
    }
}

/Abstract/IWebOrderHdRepository.cs

public interface IXcartOrdersRepository
{
    IQueryable<XcartOrder> XcartOrders { get; }
}

/Entities/WebOrderHd.cs

public class WebOrderHd
{
    [Key]
    public string PK { get; set; }
    //public string ORDERNO { get; set; }
}

And In my controller,

IWebOrderHdRepository WebOrderHdRepository = new EFWebOrderHdRepository();
int adsOrderCnt = WebOrderHdRepository.WebOrderHd.Count();

When run above code, an error occur :

The given key was not present in the dictionary.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

I guessed the error message say Asp.net can not find the PK field in WebOrderHd table,
but I am sure there is PK field.

Anybody know what I am doing wrong?

Thank You!

Stack Trace :

[KeyNotFoundException: The given key was not present in the dictionary.]
   System.Collections.Generic.Dictionary`2.get_Item(TKey key) +9619597
   Advantage.Data.Provider.AdsProviderManifest.GetStoreType(TypeUsage edmType) +2930
   System.Data.Entity.ModelConfiguration.Edm.Services.StructuralTypeMappingGenerator.MapTableColumn(EdmProperty property, DbTableColumnMetadata tableColumnMetadata, Boolean isInstancePropertyOnDerivedType, Boolean isKeyProperty) +60
   System.Data.Entity.ModelConfiguration.Edm.Services.PropertyMappingGenerator.Generate(EdmEntityType entityType, IEnumerable`1 properties, DbEntitySetMapping entitySetMapping, DbEntityTypeMappingFragment entityTypeMappingFragment, IList`1 propertyPath, Boolean createNewColumn) +1293
   System.Data.Entity.ModelConfiguration.Edm.Services.EntityTypeMappingGenerator.Generate(EdmEntityType entityType, DbDatabaseMapping databaseMapping) +496
   System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.GenerateEntityTypes(EdmModel model, DbDatabaseMapping databaseMapping) +122
   System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.Generate(EdmModel model) +30
   System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo) +189
   System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +59
   System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +62
   System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +117
   System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +453
   System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18
   System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +57
   System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
   System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +37
   System.Linq.Queryable.Count(IQueryable`1 source) +50
   SportsStore.WebUI.Controllers.ProductController.List(String category, Int32 page) in C:\Users\mark\documents\visual studio 2010\Projects\SportsStore\SportsStore.WebUI\Controllers\ProductController.cs:37
   lambda_method(Closure , ControllerBase , Object[] ) +151
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
   System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
   System.Web.Mvc.Controller.ExecuteCore() +116
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969117
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Table Structure

CREATE TABLE WEBORDERHD ( 
      PICKNO Char( 9 ),
      STATION Char( 10 ),
      CUSTNO Char( 32 ),
      COMPANY Char( 35 ),
      BNAME Char( 255 ),
      ADDRESS1 Char( 30 ),
      ADDRESS2 Char( 30 ),
      CITY Char( 64 ),
      STATE Char( 2 ),
      ZIP Char( 10 ),
      SCOMPANY Char( 35 ),
      SNAME Char( 255 ),
      SADDRESS1 Char( 30 ),
      SADDRESS2 Char( 30 ),
      SCITY Char( 64 ),
      SSTATE Char( 2 ),
      SZIP Char( 10 ),
      SALESPN Char( 10 ),
      TAXRATE Numeric( 6 ,3 ),
      CERTIFICA Char( 10 ),
      TOTAL Numeric( 11 ,2 ),
      CONTACT Char( 15 ),
      TITLE Char( 10 ),
      PHONE Char( 17 ),
      FAX Char( 17 ),
      BEEPER Char( 17 ),
      FREIGHT Numeric( 11 ,2 ),
      FINVNO Char( 6 ),
      CUSTNOTE Memo,
      MEMO Memo,
      MODDATE Date,
      PRNDATE Date,
      SHIPVIA Char( 15 ),
      SHIPDATE Date,
      DATE Date,
      STATUS Char( 30 ),
      EMAIL Char( 128 ),
      TAX Numeric( 11 ,2 ),
      PAYTYPE Char( 20 ),
      PAYREF Char( 20 ),
      CCREF Char( 50 ),
      PK Char( 36 ),
      ORDTIME Char( 8 ),
      SHIPMETHOD Char( 30 ),
      PROCSTATUS Char( 20 ),
      CUSTOMERPONO Char( 50 ),
      CUSTOMERJOBNO Char( 50 ),
      CUSTOMERPOCONTACT Char( 50 ),
      CUSTOMERPOCOMMENT Memo,
      S_COUNTRY Char( 10 ),
      B_COUNTRY Char( 10 ),
      SHIPBRANCH Char( 3 )) IN DATABASE;
  • 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-01T09:35:40+00:00Added an answer on June 1, 2026 at 9:35 am

    I by no means am an expert at EF but… have you tried making the PK property virtual? My understanding is EF needs to create a proxy with your models so they have to be virtual so it can implement it the way it needs.

    [Key]    
    public virtual string PK { get; set; }
    

    Also, I would recommend trying to access the data without an advanced pattern first that way you can verify the basics work. I always add a separate console project and test things in there as you don’t have to create a whole page just to see the results.

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

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I want to construct a data frame in an Rcpp function, but when I
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am confused How to use looping for Json response Array in another Array.
I am trying to understand how to use SyndicationItem to display feed which is

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.