This question is locked. New answers and comments are not allowed.
Hi,
i am using Telerik OpenAccess ORM 2012.2.607.1
Creating the empty domain model with MySQL backend in Visual Studio 2010 SP1 using Telerik ORM Designer (Create Domain Model -> Empty model, etc...).
Identity mechanism: HighLow
I've created User table and UserDetails table with 1:1 association (User can have 1 (One) instance of UserDetails), bind by User.Id <---> UserDetails.Id.
All tables are mapped (using the "Map to table..." command).
The following script is being executed against DB to create the tables and constraints:
The following code is being executed after that:
So in mySQL database i got next data (represented as CSV):
Table "Usr"
Table "UserDetails"
When selecting the data with the C# code below:
i've got the user object instance created well, but the UserDetails property is equals to null.
In other hand, when i selecting the first record (id == 1) like that:
I've got details record, but it is not the expected behavior.
It's clear for me that there is an issue with Identity, so i've tried to put the Identity by hand (detials.Id = 2) when creating the details, but it does not work (It will put the value "1" to the Details table instead).
Could you please direct me to the right way to accomplish my goal? Thanks!
p.s. Attaching my project : http://www.4shared.com/zip/UGw6IzNa/ConsoleApplication1.html
i am using Telerik OpenAccess ORM 2012.2.607.1
Creating the empty domain model with MySQL backend in Visual Studio 2010 SP1 using Telerik ORM Designer (Create Domain Model -> Empty model, etc...).
Identity mechanism: HighLow
I've created User table and UserDetails table with 1:1 association (User can have 1 (One) instance of UserDetails), bind by User.Id <---> UserDetails.Id.
All tables are mapped (using the "Map to table..." command).
The following script is being executed against DB to create the tables and constraints:
-- ConsoleApplication1.UserDetails
CREATE
TABLE
`user_details` (
`id`
integer
NOT
NULL
,
-- _id
`email`
varchar
(255)
NULL
,
-- _email
CONSTRAINT
`pk_user_details`
PRIMARY
KEY
(`id`)
) ENGINE = InnoDB;
-- ConsoleApplication1.User
CREATE
TABLE
`usr` (
`user_name`
varchar
(255)
NULL
,
-- _userName
`id`
integer
NOT
NULL
,
-- _id
CONSTRAINT
`pk_usr`
PRIMARY
KEY
(`id`)
) ENGINE = InnoDB;
-- OpenAccessRuntime.Relational.sql.HighLowRelationalKeyGenerator
CREATE
TABLE
`voa_keygen` (
`table_name`
VARCHAR
(64)
NOT
NULL
,
`last_used_id`
INTEGER
NOT
NULL
,
CONSTRAINT
`pk_voa_keygen`
PRIMARY
KEY
(`table_name`)
) ENGINE = InnoDB;
ALTER
TABLE
`user_details`
ADD
CONSTRAINT
`ref_user_details_usr`
FOREIGN
KEY
`ref_user_details_usr` (`id`)
REFERENCES
`usr` (`id`);
The following code is being executed after that:
EntitiesModel model =
new
EntitiesModel(
"Server=192.168.1.55;Database=test;Uid=user;Pwd=pass;"
);
model.Add(
new
User { UserName =
"test 1"
});
model.Add(
new
User { UserName =
"test 2"
, UserDetails =
new
UserDetails { Email =
"test2@email.tst"
} });
model.SaveChanges();
So in mySQL database i got next data (represented as CSV):
Table "Usr"
user_name,id
"test 1"
,
1
"test 2"
,
2
Table "UserDetails"
id,email
1
,"test
2
@email.tst"
When selecting the data with the C# code below:
EntitiesModel model =
new
EntitiesModel(
"Server=192.168.1.55;Database=test;Uid=user;Pwd=pass;"
);
User user = model.GetAll<User>().FirstOrDefault(x => x.UserName ==
"test 2"
);
UserDetails details = user.UserDetails;
// ?? <--- details == null... why ??
i've got the user object instance created well, but the UserDetails property is equals to null.
In other hand, when i selecting the first record (id == 1) like that:
User user = model.GetAll<User>().FirstOrDefault(x => x.UserName ==
"test 1"
);
UserDetails details = user.UserDetails;
// ?? <--- details are not null here
I've got details record, but it is not the expected behavior.
It's clear for me that there is an issue with Identity, so i've tried to put the Identity by hand (detials.Id = 2) when creating the details, but it does not work (It will put the value "1" to the Details table instead).
Could you please direct me to the right way to accomplish my goal? Thanks!
p.s. Attaching my project : http://www.4shared.com/zip/UGw6IzNa/ConsoleApplication1.html