-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrations: Allow many properties mapped to one column #3061
Comments
I'm currently running into a similar problem, where I have tow derived types, both with a navigation named "Reference" to a referenced type. Database creation for SQL-Server fails (cannot have two equally named columns). I would not expect this to work out-of-the-box, but every workaround I tried also fails. Here's the entities:
And here is the context:
Here is the workaround that should work:
Setting MaxLength to 450 is due to the fact that, at least on SQL Server, string-Keys are of type varchar(450). This fails: Column 'ReferencedType.Id' is not the same data type as referencing column 'BaseType.ReferenceId1' in foreign key 'FK_InheritedType1_ReferencedType_ReferenceId1'. Once you set the column types explicitly, it works:
This is odd since everything ends up being nvarchar anyway, the keys end up nvarchar(450) so setting MaxLength to 450 should be equivalent to HasSqlServerColumnType("nvarchar(450)"). The issue I'm running into is probably only #2789 in a different form, however, maybe it adds some insight into this issue as well. BTW. Does anybody know how to workaround this without setting the column types explicitly? Because I do not want to include anything about the eventual storage in my contexts. UPDATE: It seems that MaxLength is not reflected on SQL-Server, string-properties are created as nvarchar(max) column. I'm still investigating this since according to #2703 this should have been fixed. |
This is to unblock the scenario where two derived types have properties with the same name that could be mapped to the same property in TPH.
For the first iteration we could just use the column generated from either property.
As a minimal safeguard we could throw if the generated columns are different in any way, without trying to merge the configurations.
The text was updated successfully, but these errors were encountered: