npoco


NPoco mapping primarykey error


I am experimenting with NPoco and immediately ran into an issue with a primary key error. I'm using the class below and the database table is called tblSessionInfo. If I create a new SessionInfo and attempt to save it I get "The object doesn't have a property matching the primary key column name 'ID'". If I retrieve a record from the db and inflate a SessionInfo and then try to save it I get "The object doesn't have a property matching the primary key column name 'ID'". It seems that NPoco is not acknowledging the PrimaryKey attribute. When I debug my code I can step through the Column attribute bindings never the PrimaryKey attribute binding though. I pulled the attribute classes from PetaPoco's implementation.
[TableName("tblSessionInfo")]
[PrimaryKey("SessionId")]
[ExplicitColumns]
public class SessionInfo
{
#region Properties
public int SessionId { get; set; }
[Column("SessionCreated")]
public DateTime? SessionCreated { get; set; }
[Column("SessionUpdated")]
public DateTime? SessionUpdated { get; set; }
[Column("SessionEnded")]
public DateTime? SessionEnded { get; set; }
[Column("SessionData")]
public string SessionData { get; set; }
[Column("ApplicationId")]
public int? ApplicationId { get; set; }
[Column("Expired")]
public bool? Expired { get; set; }
#endregion
}

Related Links

NPoco mapping primarykey error
Nopoc Execute() method returns -1
Creating a new database using NPoco
Creating Custom Ignore attribute only for Update methods?
NPoco One-To-Many and Many-To-Many
Any example of using join in query applyable for npoco
How do I format a query to fetch an aggregate root with just related ids

Categories

HOME
oauth-2.0
asterisk
drupal
oop
javafx
google-cloud-pubsub
display
cryengine
query-string
datetimepicker
rethinkdb
doctrine2
restheart
promotions
cracking
suitecrm
vichuploaderbundle
point-of-sale
decoding
element
saucelabs
box2d
alert
klipfolio
suitescript
scalatest
expressionengine
mex
typeorm
ios9
textview
visual-studio-debugging
ilog
machine-code
idea-plugin
redbean
java-5
amazon-fire-tv
togglebutton
dcom
perldoc
aot
blackberry
codesniffer
scrollmagic
pyautogui
google-scholar
dimensionality-reduction
jira-agile
key-value-store
radar-chart
cexception
askbot
wiql
recode
windows-kernel
properties-file
euro
eula
transparentproxy
data-representation
crtdbg.h
qxorm
drools-guvnor
information-hiding
azure-worker-roles
im4java
nest-initiative
mongoid4
android-jack-and-jill
ojb
xrandr
http-compression
cocotron
phone-state-listener
setcookie
libx264
win-prolog
datejs
cgaffinetransform
pex-and-moles
sessiontracking
xhtmlrenderer
cryptolicensing
xslt-grouping
dgml
web-widget
file-storage
script-tag
qlibrary
disk-based

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App