Bug #62185 | Table name ignored with Entity Framework Code First | ||
---|---|---|---|
Submitted: | 16 Aug 2011 23:06 | Modified: | 6 Nov 2011 22:17 |
Reporter: | Alexandr Ponomarenko | Email Updates: | |
Status: | No Feedback | Impact on me: | |
Category: | Connector / NET | Severity: | S2 (Serious) |
Version: | 6.4.3 | OS: | Any |
Assigned to: | Assigned Account | CPU Architecture: | Any |
Tags: | Code First, Contribution, EF, fluent API |
[16 Aug 2011 23:06]
Alexandr Ponomarenko
[16 Aug 2011 23:12]
Alexandr Ponomarenko
File with fix
Attachment: ProviderServices.cs (text/plain), 18.59 KiB.
[18 Aug 2011 12:16]
Alexandr Ponomarenko
and one more fix in GetTableCreateScript: private string GetTableCreateScript(EntitySet entitySet) { EntityType e = entitySet.ElementType; StringBuilder sql = new StringBuilder("CREATE TABLE "); string tableName = (string)entitySet.MetadataProperties["Table"].Value == null ? e.Name : (string)entitySet.MetadataProperties["Table"].Value; sql.AppendFormat("`{0}`(", tableName); string delimiter = ""; bool hasPK = false; foreach (EdmProperty c in e.Properties) { Facet facet; hasPK = hasPK || (c.TypeUsage.Facets.TryGetValue("StoreGeneratedPattern", false, out facet) && facet.Value.Equals(StoreGeneratedPattern.Identity)); sql.AppendFormat("{0}{1}\t`{2}` {3}{4}", delimiter, Environment.NewLine, c.Name, GetColumnType(c.TypeUsage), GetFacetString(c)); delimiter = ", "; } sql.AppendLine(");"); sql.AppendLine(); if (!hasPK && e.KeyMembers.Count > 0) { sql.Append(String.Format( "ALTER TABLE `{0}` ADD PRIMARY KEY (", tableName)); delimiter = ""; foreach (EdmMember m in e.KeyMembers) { sql.AppendFormat("{0}{1}", delimiter, m.Name); delimiter = ", "; } sql.AppendLine(");"); sql.AppendLine(); } return sql.ToString(); }
[18 Aug 2011 12:17]
Alexandr Ponomarenko
Updated ProviderServices.cs
Attachment: ProviderServices.cs (text/plain), 18.61 KiB.
[6 Oct 2011 22:17]
Fernando Gonzalez.Sanchez
Thanks for your report Alexandr, This fix was already made in http://bugs.mysql.com/bug.php?id=61230, as such I couldn't reproduce it in v.6.4.4 (ie. it is already naming the table as specified in OnModelCreating override). Can you confirm this is fixed in 6.4.4? Thanks.
[7 Nov 2011 0:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".