Solved

Change FK key name Ef framework Code First

Posted on 2010-09-15
2
572 Views
Last Modified: 2013-11-07
Hi!
I'm using Ef Code first to map my database. I have a 1-m relation and the  default convention is POccurrence_id but ofc it cant find it, coz in my DB its named fkOccurrenceId.

How do i map the new FK name?

Best regards
Bjorn
0
Comment
Question by:YouKnowPochen
2 Comments
 
LVL 51

Expert Comment

by:Mark Wills
ID: 33690606
Well, the FK is not normally mapped to, rather it establishes indexes and a relationship between two tables so should use relatedto, and the mapping uses the FK key (because of the indexes).

"normal" naming conventions would suggest that the foreign key is likely to start with fk... and that is not the column in the database necessarily.

You will need to double check the tables specifically to clarify the naming conventions, or rather, the actual table and columns (and any constraints).
0
 

Accepted Solution

by:
YouKnowPochen earned 0 total points
ID: 33690910
Or i could use the DataAnnotation attribute RelatedTo, works just fine, but thank you for the answer.
And theconvention does not go with fk in the beginning i guess, since it was looking for fktablename_id
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now