Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Change FK key name Ef framework Code First

Posted on 2010-09-15
2
Medium Priority
?
580 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

604 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