timabell / ef-enum-to-lookup

Generates lookup tables from enum references in Microsoft Entity Framework 6.1
https://www.nuget.org/packages/ef-enum-to-lookup
69 stars 29 forks source link

problem with Persian Description attribute on enum field #12

Closed hpourjam closed 9 years ago

hpourjam commented 9 years ago

Setting Persian Description attribute cause the table generated in database to have names like ??????.

timabell commented 9 years ago

Thanks for your bug report, I'm afraid I'm not that hot on i18n; but if anyone can provide a pull request that fixes this I'd be happy to integrate it. Character encodings is on my list of things to properly get the hang of, but I wouldn't hold out for a fix from me any time soon :-)

hpourjam commented 9 years ago

I just figure out the problem, the problem was about collation, if target database does not support Persian language, characters of DescriptionAttribute contains Persian text will be converted to question mark "?", so I changed the collation of my target database and new exception comes up, "Cannot resolve the collation conflict between ....", I figure out that the problem is in PopulateLookup Method, it uses a temp table, this temp table is generated in tempdb in system databases, and because the collation of these two databases is different the problem raises, I fixed the issue by changing the name of temp table from "#lookup" to "string.Format("_TempEnum{0}", TableName(lookup.Name))", This change makes the temp table to be generated in the target database instead of tempdb and the problem resolved.

I don't know whether this is a good approach or not, but it solved my problem.

timabell commented 9 years ago

Looks like we can set the collation for the temp tables when they are created. http://stackoverflow.com/a/6073169/10245

timabell commented 9 years ago

Fixed in 8e0076d03395a77c0f18a487361d56257f198a90 and released in v1.2.2, updated package now available via nuget. Let me know if that fixes it for you. Thanks for getting stuck in!

hpourjam commented 9 years ago

yes it is fixed now, thank you.