Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7829615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:51:06+00:00 2026-06-02T10:51:06+00:00

I have the following entity: public class User { public int ID {get; set;}

  • 0

I have the following entity:

public class User
{
    public int ID {get; set;}

    public int GroupID {get; set;}     // navigation property with 
    public Group Group {get; set;}     // foreign key field

    public Adress Adress {get; set;}   // navigation property only

}

The table generated from entity framework looks like:

ID
GroupID
Adress_ID

I don’t like, that the column naming for the FK columns is not the same. Can I achieve that both use the same convention either “GroupID, AdressID” or “Group_ID, Adress_ID”?

I use convention over configuration and don’t want to use Fluent API.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:51:10+00:00Added an answer on June 2, 2026 at 10:51 am

    EF 4.1 to 4.3 doesn’t support creating custom conventions, so it’s not possible. The only thing you can do (without Fluent API) is probably mapping the foreign property to another column name:

    [Column("Group_ID")]
    public int GroupID {get; set;}
    

    Then you have both FK columns with underscore in the database. But – as you can see – you need to overwrite the conventions with data annotations at least.

    Defining the second FK column without underscore is only possible with Fluent API:

    modelBuilder.Entity<User>()
        .HasOptional(u => u.Address)
        .WithMany()
        .Map(x => x.MapKey("AddressID"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following objects: public class User { int Id { get; set;
I have the following model entity: public class ScheduledTask { public virtual int ScheduledTaskId
Assume I have the following two classes: public class User : Entity { public
I have the following java class: package domain; //imports @Entity public class User {
I have the following @OneToOne relation: @Entity @Table(name=USER) public class User implements Serializable{ private
I have the following code: modelBuilder.Entity<User>().HasMany(x => x.Items).WithRequired(); The model looks like public class
I have the following entity public class DocumentHistory { public string Name { get;
my application has the following entity: public class User { public virtual int UserID
So I have the following models public class User { public int Id {
Say, I have following entities: @Entity public class A { @Id @GeneratedValue private Long

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.