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 8692357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:17:53+00:00 2026-06-13T00:17:53+00:00

Scenario seems to be trivial and I’m really confused on what I’m doing wrong.

  • 0

Scenario seems to be trivial and I’m really confused on what I’m doing wrong.

So, I have a Client class

 public class Client
{
    [Key]
    public int ClientID { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }

    public virtual Account Account { get; set; }

 }

Employee class

public class Employee
{
    [Key]
    public int EmployeeID { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }

    public virtual Account Account { get; set; }
}

and an Account class

public class Account
{
    [Key]
    public int AccountID { get; set; }
    public string Login { get; set; }
    public string Password { get; set; }

    public virtual Employee Employee { get; set; }
    public virtual Client Client { get; set; }
}

Both Client and Employee may have an Account or not ( online access is optional ). As database is not compatible with EF namingconvention I have to come up with Fluent API explicit mappings.

Both Client and Employee tables have “AccountID” column that I’m trying to use to build a relation.

        modelBuilder.Entity<Client>()
            .HasOptional(e => e.Account)
            .WithRequired(a => a.Client)
            .Map(m => m.MapKey("AccountID"));

        modelBuilder.Entity<Employee>()
            .HasOptional(e => e.Account)
            .WithRequired(a => a.Employee)
            .Map(m => m.MapKey("AccountID"));

but I get

Schema specified is not valid. Errors: 
(15,6) : error 0019: Each property name in a type must be unique. Property name 'AccountID' was already defined.
(16,6) : error 0019: Each property name in a type must be unique. Property name 'AccountID' was already defined.

so, is there a way to fix this other than modification of the table/entity structure?

  • 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-13T00:17:54+00:00Added an answer on June 13, 2026 at 12:17 am

    Turns out you don’t need Fluent API in this case, what you need is to DataAnnotate your properties in Entities with InverseProperty attribute

    [InverseProperty("AccountID")]
    

    There is a great answer by Ladislav Mrnka in Entity Framework 4.1 InverseProperty Attribute question

    However if anyone knows how to do that correctly with Fluent answers are highly appreciated

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Issue Seems like the condition gets ignored. Here is my scenario: Source class public
I have what seems to me as a bit of an odd scenario, well
i have what seems like a basic scenario for a db trigger in SQL
I need to log some events on a Clojure Client-Server scenario, but it seems
I get confused sometimes when working with CG elements, and have the following scenario
it seems that I have a problem with my multibinding. Scenario: I have a
Scenario I've written a WMI Wrapper that seems to be quite sufficient, however whenever
Seems like a standard approach for an ioc when given a scenario like (C#
This seems like a common scenario with an obvious solution, but somehow I haven't
The error message seems to be little mis-leading with the scenario, when we try

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.