No PK Defined FetchEntity

Posts   
 
    
MarkD
User
Posts: 5
Joined: 02-Feb-2012
# Posted on: 02-Feb-2012 16:45:33   

I have a sql table called UserDashboard with column called UserID and is defined as a PK. I generate the entity classes and the UserDashboardEntity.vb class is created. When I call the following, i get an error that

    Dim dataAccessAdapter As New DataAccessAdapter
    Dim userID As Integer = Owner.GetUserID

    Dim UserDashboard As New UserDashboardEntity(Convert.ToInt32(userID))

error occurs here --> dataAccessAdapter.FetchEntity(UserDashboard)

Error message The entity 'UserDashboardEntity' doesn't have a PK defined, and FetchEntity therefore can't create a query to fetch it. Please define a PK on the entity

version info for SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll is 2.5.8.328

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Feb-2012 21:49:27   

Please post the full stack trace.
Also, check whether that field is marked as primary key in your LLBLGen project.

David Elizondo | LLBLGen Support Team
MarkD
User
Posts: 5
Joined: 02-Feb-2012
# Posted on: 02-Feb-2012 22:02:28   

?ex {"The entity 'UserDashboardEntity' doesn't have a PK defined, and FetchEntity therefore can't create a query to fetch it. Please define a PK on the entity"} SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryConstructionException: {"The entity 'UserDashboardEntity' doesn't have a PK defined, and FetchEntity therefore can't create a query to fetch it. Please define a PK on the entity"} Data: {System.Collections.ListDictionaryInternal} HelpLink: Nothing InnerException: Nothing Message: "The entity 'UserDashboardEntity' doesn't have a PK defined, and FetchEntity therefore can't create a query to fetch it. Please define a PK on the entity" Source: "SD.LLBLGen.Pro.ORMSupportClasses.NET20" StackTrace: " at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntity(IEntity2 entityToFetch, IPrefetchPath2 prefetchPath, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields) at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntity(IEntity2 entityToFetch) at Dashboard.LoadStateFromSession() in C:\Projects\MarketingProjectManagement\Modules\UserControl\Dashboard\Dashboard.ascx.vb:line 48" TargetSite: {System.Reflection.RuntimeMethodInfo}

MarkD
User
Posts: 5
Joined: 02-Feb-2012
# Posted on: 02-Feb-2012 22:03:05   

where do i check in the LLBLGen project that field is marked as primary key?

MarkD
User
Posts: 5
Joined: 02-Feb-2012
# Posted on: 02-Feb-2012 22:13:05   

Yes, it shows (PK) next to UserId in the project

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Feb-2012 03:01:57   

And, are you sure your project is in sync with your code? That means double-check you are generating code to the appropriate location and re-generate just to make sure you didn't make some changes that are not reflected in your code.

If the problem persists please prepare a tiny repro solution that reproduce the problem: a SQL DDL script, your llblgen project file and the code (without bin/ folder nor dll's). Then zip all that and attach it to the thread so we can reproduce the problem. If you want you can create a new HelpDesk thread, which is private to do so.

David Elizondo | LLBLGen Support Team