Comments (5)
Check out https://github.com/alexwiese/EntityFrameworkCore.OpenEdge#gotchas
Basically EF Core thinks they are all the same record as the "ID" is the same.
You need a unique column to act as the ID. If you don't have one then add RowId as per that link
from entityframeworkcore.openedge.
Huh. I read that, but these tables have "keys" in that they have an index...but I suppose it's not actually unique. I'll add that to each of my models and see what happens, thank you.
from entityframeworkcore.openedge.
So I added:
[Key]
[Column("rowid")]
public string Rowid { get; set; }
to the model class but I did not modify the context to include this column. This is the modelbuilder's entity definition:
modelBuilder.Entity<PromoTransHdr>(entity =>
{
entity.HasKey(e => new { e.ContractNo, e.ExpireDate });
entity.ToTable("promo-trans-hdr");
entity.Property(e => e.ContractNo)
.HasColumnName("contract-no")
.HasColumnType("character");
entity.Property(e => e.ExpireDate)
.HasColumnName("expire-date")
.HasColumnType("date");
entity.Property(e => e.BillingCode)
.HasColumnName("Billing-code")
.HasColumnType("character");
entity.Property(e => e.Description)
.IsRequired()
.HasColumnName("description")
.HasColumnType("character");
entity.Property(e => e.OrigAmt)
.HasColumnName("orig-amt")
.HasDefaultValueSql("0");
entity.Property(e => e.OrigDate)
.HasColumnName("orig_date")
.HasColumnType("date");
entity.Property(e => e.PromoId)
.HasColumnName("promo-id")
.HasDefaultValueSql("0");
entity.Property(e => e.PromoTransno)
.HasColumnName("promo-transno")
.HasDefaultValueSql("0");
entity.Property(e => e.Restricted)
.HasColumnName("restricted")
.HasColumnType("logical")
.HasDefaultValueSql("no");
entity.Property(e => e.TransDate)
.HasColumnName("trans-date")
.HasColumnType("date");
entity.Property(e => e.UsedAmt)
.HasColumnName("used-amt")
.HasDefaultValueSql("0");
});
This did not solve the problem.
{
"value": [
{
"rowid": "0000000000105448618",
"promoId": 103,
"transDate": "2015-11-30T00:00:00",
"description": "WarrantyPayment:1170389",
"contractNo": "Jeff",
"expireDate": "2015-12-30T00:00:00",
"origAmt": 6,
"usedAmt": 6,
"promoTransno": 137972,
"billingCode": "GBB",
"restricted": false,
"origDate": null
},
{
"rowid": "0000000000105448618",
"promoId": 103,
"transDate": "2015-11-30T00:00:00",
"description": "WarrantyPayment:1170389",
"contractNo": "Jeff",
"expireDate": "2015-12-30T00:00:00",
"origAmt": 6,
"usedAmt": 6,
"promoTransno": 137972,
"billingCode": "GBB",
"restricted": false,
"origDate": null
},
// Repeat dozens of these.
}
The "key" that EF has selected (ContractNo, ExpireDate) is actually pretty nonsensical. The key should be PromoTransno. That is also an index in the database, but it is the second index and is not marked as 'primary.'
I will try adding rowId to the modelBuilder and if that doesn't work I'll see if I can use the second index instead.
from entityframeworkcore.openedge.
Adding:
entity.HasKey(e => e.RowId);
entity.Property(e => e.RowId)
.HasColumnName("rowid");
And commenting out the bad primary index/"key" fixed the problem. Thanks a lot for your help!
from entityframeworkcore.openedge.
from entityframeworkcore.openedge.
Related Issues (16)
- Migrations do not work
- The 'OpenEdgeBoolTypeMapping' does not support value conversions. HOT 10
- Support for extent specifier? HOT 2
- Scaffold and Multi Database Connection
- [OPENEDGE]Column "TIMESTAMP" cannot be found or is not specified for query. HOT 4
- Add <owner>.pub.<table> on TableVisit HOT 1
- is OpenEdge 10.2 A version supported HOT 1
- Scaffold-DbContext doesn't work HOT 2
- Count() expects Int32. OpenEdge returns Int64 HOT 1
- How to work with datetime fields in a update transaction? HOT 2
- .Net 6 support HOT 1
- No params allowed in select list HOT 1
- PopulateDebugInfo missing HOT 6
- Tables and Columns HOT 1
- Scaffold-DbContext remoting error HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entityframeworkcore.openedge.