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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:22:08+00:00 2026-06-14T09:22:08+00:00

Firebird 2.5 Entity Framework 5 FirebirdClientDll 3.0.0.0 Hi, I’m trying to access my legacy

  • 0
  • Firebird 2.5
  • Entity Framework 5
  • FirebirdClientDll 3.0.0.0

Hi, I’m trying to access my legacy database with the Entity Framework (Code First).
I got the problem that the database does not use foreign keys…

public class CUSTOMERS
{
    public int CUSTOMERID { get; set; }
    public string NAME{ get; set; }
}

public class INVOICES
{
    public int INVOICEID{ get; set; }
    public int CUSTOMERID{ get; set; }

    public virtual CUSTOMERS CUSTOMERS { get; set; }
}

public class INVOICEContext : DbContext
{
    public DbSet<CUSTOMERS> CUSTOMERS{ get; set; }
    public DbSet<INVOICES> INVOICES{ get; set; }

    public INVOICEContext(DbConnection connectionString) : base(connectionString, false)
    {
        Database.SetInitializer<INVOICEContext>(null);
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

        /*modelBuilder.Entity<INVOICES>().HasRequired(b => b.CUSTOMERS)
                    .WithMany()
                    .Map(p => p.MapKey("INVOICEID"));*/ //Doesn't work because INVOICEID is defined

        modelBuilder.Entity<INVOICES>().HasKey(a => new { a.INVOICEID, a.CUSTOMERID});
        modelBuilder.Entity<CUSTOMERS>().HasKey(a => new { a.CUSTOMERID });

        base.OnModelCreating(modelBuilder);
    }
}

Normally I could remove the property CUSTOMERID from the class INVOICES, but in this case it is part of the primary key…

I found many threads which suggested to use IsIndependent, but it seems to be removed from the Entity Framework 5 (or 4.1).

I hope you can understand my poor English and maybe give me a hint what I’m doing wrong ^^

  • 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-14T09:22:09+00:00Added an answer on June 14, 2026 at 9:22 am

    I don’t know what you mean with “the database does not use foreign keys“. So, maybe the following is not the answer you are looking for. But I’d say that you can use your relationship mapping that is commented out in your code if you replace ...MapKey... by HasForeignKey and use CUSTOMERID instead of INVOICEID as the foreign key property:

    modelBuilder.Entity<INVOICES>()
        .HasRequired(b => b.CUSTOMERS)
        .WithMany()
        .HasForeignKey(b => b.CUSTOMERID);
    

    The model and the rest of the mapping is fine in my opinion. Your relationship is an identifying relationship (that means that the foreign key is part of a composite primary key) which is a valid mapping with Entity Framework.

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

Sidebar

Related Questions

I'm trying to connect to a Firebird database using the Zend Framework library (see
I'm trying to generate an entity model from a Firebird database using the Entity
I downloaded Firebird 2.5 and read somewhere that it supports Entity Framework. When I
How can I compact Firebird 2.1 database, like we do in MS Access (discarding
i want to backup firebird database. Below is command that i use to execute
Django's backend ( firebird ) problem reconnecting to database was fixed as here by
I'm using firebird database and it does not seem to have ROWNUM or ROW_NUMBER()
In my Firebird database I have a Blob field that contain a Bitmap. I'll
I am using Firebird in my app. There is a database that receives load
I have an existing legacy Firebird database with nonstandard table and field names. I

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.