Foreign keys between different schemas (mysql + NH)

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
DarkCamper
Posts: 12
Joined: Wed 18 Mar 2015 17:31

Foreign keys between different schemas (mysql + NH)

Post by DarkCamper » Mon 19 Mar 2018 13:36

Hi!

I have a problem when generating a model from a DB that has a table with a FK to a table in another schema. Entity Developer doesn't seem to acknowledge that the FK exists and no association between both entities is created.
If I create the association manually and then try to update the DB from the Model it says a FK needs to be created.

You can reproduce it following these steps:
1. Create two databases in mysql. Call them "SchA" an "SchB"
2. Run the following SQL Script to create 3 tables and some FKs

Code: Select all

create table SchB.TableB(id int primary key);
create table SchA.TableC(id int primary key);
create table SchA.TableA(
  id int primary key, 
  id_B int,
  id_C int, 
  FOREIGN KEY FK_TEST_B(id_B) REFERENCES SchB.TableB(id),
  FOREIGN KEY FK_TEST_C(id_C) REFERENCES SchA.TableC(id));
3. Create a new NHibernate model, DB First, and select all tables from SchA and SchB
4. The result will be something like this
Image

As you can see no association between TableA and TableB has been created, but the association between TableA and TableC has been correctly added.

I've tested this with Entity Developer Pro 6.2.439 and MySql 5.6.25

Thanks!

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Foreign keys between different schemas (mysql + NH)

Post by Shalex » Thu 22 Mar 2018 18:47

Thank you for your report. We will notify you when the issue is fixed.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Foreign keys between different schemas (mysql + NH)

Post by Shalex » Fri 27 Apr 2018 11:08

The new Retrieve Cross Database Relations option is implemented in Model Settings (Tools > Options > Servers' Options > MySQL) for detecting FK relations between tables in different databases. Please upgrade to dotConnect for MySQL v8.10.1134.

Leads to performance loses when retrieving metadata, you should increase value of the Default Command Timeout connection string parameter.

DarkCamper
Posts: 12
Joined: Wed 18 Mar 2015 17:31

Re: Foreign keys between different schemas (mysql + NH)

Post by DarkCamper » Thu 31 May 2018 10:51

I've just tested the new "Retrieve Cross Database Relations" option and it seems to work just fine :)

Thanks a lot!

Post Reply