Skip to content

Commit

Permalink
Distinguishing Foreign Keys with same name on different tables (and same
Browse files Browse the repository at this point in the history
for indexes). Also guarding against bad metadata and adding warning
messages.
  • Loading branch information
lajones committed Dec 1, 2015
1 parent 15be8b4 commit 454968a
Show file tree
Hide file tree
Showing 6 changed files with 267 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.tt</DependentUpon>
</Compile>
<Compile Include="Internal\SqlDataReaderExtensions.cs" />
<Compile Include="SqlServerTableSelectionSetExtensions.cs" />
<Compile Include="SqlServerDesignTimeServices.cs" />
<Compile Include="SqlServerScaffoldingModelFactory.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Data.SqlClient;
using JetBrains.Annotations;

namespace Microsoft.Data.Entity.Scaffolding.Internal
{
public static class SqlDataReaderExtensions
{
public static string GetStringOrNull([NotNull] this SqlDataReader reader, int ordinal)
{
return reader.IsDBNull(ordinal) ? null : reader.GetString(ordinal);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,34 @@
<data name="CannotInterpretSqlServerStringLiteral" xml:space="preserve">
<value>Unable to interpret the string {sqlServerStringLiteral} as a SQLServer string literal.</value>
</data>
<data name="ColumnNameEmptyOnForeignKey" xml:space="preserve">
<value>Found a column on foreign key [{schemaName}].[{tableName}].[{fkName}] with an empty or null name. Not including column in foreign key</value>
</data>
<data name="ColumnNameEmptyOnIndex" xml:space="preserve">
<value>Found a column on index [{schemaName}].[{tableName}].[{indexName}] with an empty or null name. Not including column in index.</value>
</data>
<data name="ColumnNameEmptyOnTable" xml:space="preserve">
<value>Found a column on table [{schemaName}].[{tableName}] with an empty or null name. Skipping column.</value>
</data>
<data name="DataTypeDoesNotAllowSqlServerIdentityStrategy" xml:space="preserve">
<value>For column {columnId}. This column is set up as an Identity column, but the SQL Server data type is {sqlServerDataType}. This will be mapped to CLR type byte which does not allow the SqlServerValueGenerationStrategy.IdentityColumn setting. Generating a matching Property but ignoring the Identity setting.</value>
</data>
<data name="IndexNameEmpty" xml:space="preserve">
<value>Found an index on table [{schemaName}].[{tableName}] with an empty or null name. Skipping index.</value>
</data>
<data name="UnableToConvertDefaultValue" xml:space="preserve">
<value>For column {columnId} unable to convert default value {defaultValue} into type {propertyType}. Will not generate code setting a default value for the property {propertyName} on entity type {entityTypeName}.</value>
</data>
<data name="UnableToFindColumnForForeignKey" xml:space="preserve">
<value>Foreign Key {fkName} contains a column named {columnName} which cannot be found on table [{schemaName}].[{tableName}]. Not including column in foreign key.</value>
</data>
<data name="UnableToFindColumnForIndex" xml:space="preserve">
<value>Index {indexName} contains a column named {columnName} which cannot be found on table [{schemaName}].[{tableName}]. Not including column in index.</value>
</data>
<data name="UnableToFindTableForColumn" xml:space="preserve">
<value>For column {columnName}. Unable to find parent table [{schemaName}].[{tablename}]. Skipping column.</value>
</data>
<data name="UnableToFindTableForIndex" xml:space="preserve">
<value>For index {indexName}. Unable to find parent table [{schemaName}].[{tableName}]. Skipping index.</value>
</data>
</root>
Loading

0 comments on commit 454968a

Please sign in to comment.