Issue Details (XML | Word | Printable)

Key: DNET-379
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Jiri Cincura
Reporter: Leonard Wennekers
Votes: 1
Watchers: 1

If you were logged in you would be able to see more operations.
.NET Data provider

Entity framework CreateDatabaseScript gives false results

Created: 13/May/11 08:06 AM   Updated: 01/Aug/12 03:40 PM
Component/s: ADO.NET Provider
Affects Version/s: 2.6
Fix Version/s:

File Attachments: 1. File SSDLToFB.cs (23 kB)
2. Zip Archive (3.70 MB)

Environment: Windows 7

 Description  « Hide
The result of the CreateDatabaseScript function from the EntityFramework gives a false result. The TableNames is uses are just the names of the Entity and not the real tablenames configured by it's configurations. The bug commes inside SSDLToFB.cs where I did some trials.

The same function CreateDatabaseScript also create some errors with associations. The maximum length of associations is 32 charaters by with the CreateDatabaseScript function they can bw much longer because they are concatinated from the entity names. This also gives some problems when using the script created.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Leonard Wennekers added a comment - 13/May/11 08:08 AM
The files has some comments with the text


After this test a fix is made for creating the right tablenames for the CreateDatabaseScript function/

However for the length of the associations there is nothing done.

Jiri Cincura added a comment - 14/May/11 03:10 PM
Thanks for reporting, although the patch is wrong. The code is generated form T4 template and the template itself must be independent (because it might be run outside provider).

Jens Duczmal added a comment - 16/Apr/12 08:05 AM - edited
Dear Jiri,

it seems, that the TableAttribute is still ignored. CreateDatabaseScript does contain only the Classname as Tablename, not the string declared in [Table("DifferentName)"]-Attribute.

Any Ideas, when this might be fixed? It will be very useful, if we could use CodeFirst inkl. generation Script.

Edit: Version 2.7 (and probably 2.7.5 as well, becuase this ticket ist still open)

Jiri Cincura added a comment - 16/Apr/12 10:55 AM
Probably after 2.8 is out.

Jens Duczmal added a comment - 16/Apr/12 11:12 AM
Hm....anyway, thanks for this reply.

Remapping of Colum-Names does work already very well. Just the Tablename does make problems.
I believe the foreign-key-problematic might be much more difficult to fix, but I could live with this for the time being.

I would be very grateful if you could try to get the Table-Attribute fixed within 2.8.
All our Tables have Prefixes, and - unfortunetely - the prefixes are Numeric, so I just have no possibility to refactor my classes,
because a class can't start with a number. Of course, that's our problem, but because reading data does work very well
and it's just a matter of the ScriptCreation it's a bit disappointing.

We are struggling just 10 meters in front of the finishing line.

Jiri Cincura added a comment - 30/Jul/12 03:29 PM
I'm trying it right now, and I have my EDMX model with entity name different from table name and the call to CreateDatabaseScript (on ObjectContext) gives right result. Can you provide a test case?

Jens Duczmal added a comment - 30/Jul/12 03:44 PM
Thanks, I appreciate this good news :)

I can send you something tomorrow morning GMT.
But I tried with CodeFirst, i.e. without EDMX. And I used the Table-Annotation like

public class Customer {
    public int ID {get;set;}
    public string Name {get;set;}
    public string Town {get;set;}

The Column-Tag for renaming a Column does work fine. But the similar Table-Tag does not.
But in order to be really sure I will test this tomorrow morning and I will attach a C#-File or send it by mail.

Leonard Wennekers added a comment - 31/Jul/12 08:22 AM
Thanks Jens for creating the test. I searched for my test but I lost It.
And Jiri good luck with fixing this bug.

Jens Duczmal added a comment - 31/Jul/12 11:06 AM
Sample file for CodeFirst with Table-Annotation

Jens Duczmal added a comment - 31/Jul/12 11:10 AM
Sorry, the file is as big because I mistakely zipped the EF-Nuget-Package.

Just create an empty Database, change the file and start it.
You will see that for the Town-Property a field named "City" would be created.
But the Table will have still the name "Customer" instead of "MyCustomer".

Probably not the best example, but I'm not able to get "DropCreateDatabaseInitializer" running with Firebird.
So you have to create one empty by yourself.

Jens Duczmal added a comment - 01/Aug/12 03:40 PM
Thank you, Jiri.
Keep up the great work.