src/Shared/EntityFramework/Migrations/Builders/TableBuilder.cs
/// <summary>
/// Specifies a foreign key constraint to be created on the table.
///
/// Entity Framework Migrations APIs are not designed to accept input provided by untrusted sources 
/// (such as the end user of an application). If input is accepted from such sources it should be validated 
/// before being passed to these APIs to protect against SQL injection attacks etc.
/// </summary>
/// <param name="principalTable"> Name of the table that the foreign key constraint targets. </param>
/// <param name="dependentKeyExpression"> A lambda expression representing the properties of the foreign key. C#: t => t.PropertyOne VB.Net: Function(t) t.PropertyOne If multiple properties make up the foreign key then specify an anonymous type including the properties. C#: t => new { t.PropertyOne, t.PropertyTwo } VB.Net: Function(t) New With { t.PropertyOne, t.PropertyTwo } </param>
/// <param name="cascadeDelete"> A value indicating whether or not cascade delete should be configured on the foreign key constraint. </param>
/// <param name="name"> The name of this foreign key constraint. If no name is supplied, a default name will be calculated. </param>
/// <param name="anonymousArguments"> Additional arguments that may be processed by providers. Use anonymous type syntax to specify arguments e.g. 'new { SampleArgument = "MyValue" }'. </param>
/// <returns> Itself, so that multiple calls can be chained. </returns>
Specifies a foreign key constraint to be created on the table.

Entity Framework Migrations APIs are not designed to accept input provided by untrusted sources
(such as the end user of an application). If input is accepted from such sources it should be validated
before being passed to these APIs to protect against SQL injection attacks etc.
Specifies a foreign key constraint to be created on the table . Entity Framework Migrations APIs are not designed to accept input provided by untrusted sources ( such as the end user of an application ) . If input is accepted from such sources it should be validated before being passed to these APIs to protect against SQL injection attacks etc .
[SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
        [SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
        [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        public TableBuilder<TColumns> ForeignKey(
            string principalTable,
            Expression<Func<TColumns, object>> dependentKeyExpression,
            bool cascadeDelete = false,
            string name = null,
            object anonymousArguments = null)
        {
            Check.NotEmpty(principalTable, "principalTable");
            Check.NotNull(dependentKeyExpression, "dependentKeyExpression");
            var addForeignKeyOperation = new AddForeignKeyOperation(anonymousArguments)
                {
                    Name = name,
                    PrincipalTable = principalTable,
                    DependentTable = _createTableOperation.Name,
                    CascadeDelete = cascadeDelete
                };
            dependentKeyExpression
                .GetSimplePropertyAccessList()
                .Select(p => _createTableOperation.Columns.Single(c => c.ApiPropertyInfo == p.Single()))
                .Each(c => addForeignKeyOperation.DependentColumns.Add(c.Name));
            _migration.AddOperation(addForeignKeyOperation);
            return this;
        }
[ SuppressMessage ( " " , " " ) ] [ SuppressMessage ( " " , " " ) ] [ SuppressMessage ( " " , " " ) ] public TableBuilder < TColumns > ForeignKey ( string principalTable , Expression < Func < TColumns , object > > dependentKeyExpression , bool cascadeDelete = false , string name = null , object anonymousArguments = null ) { Check . NotEmpty ( principalTable , " " ) ; Check . NotNull ( dependentKeyExpression , " " ) ; var addForeignKeyOperation = new AddForeignKeyOperation ( anonymousArguments ) { Name = name , PrincipalTable = principalTable , DependentTable = _createTableOperation . Name , CascadeDelete = cascadeDelete } ; dependentKeyExpression . GetSimplePropertyAccessList ( ) . Select ( p => _createTableOperation . Columns . Single ( c => c . ApiPropertyInfo == p . Single ( ) ) ) . Each ( c => addForeignKeyOperation . DependentColumns . Add ( c . Name ) ) ; _migration . AddOperation ( addForeignKeyOperation ) ; return this ; }
Specifies a foreign key constraint to be created on the table.
Specifies a foreign key constraint to be created on the table .
Itself, so that multiple calls can be chained.
Itself so that multiple calls can be chained .
principalTable
string
Name of the table that the foreign key constraint targets.
Name of the table that the foreign key constraint targets .
dependentKeyExpression
Expression<Func<TColumns, object>>
A lambda expression representing the properties of the foreign key. C#: t => t.PropertyOne VB.Net: Function(t) t.PropertyOne If multiple properties make up the foreign key then specify an anonymous type including the properties.
A lambda expression representing the properties of the foreign key . C# : t = > t . PropertyOne VB . Net : Function ( t ) t . PropertyOne If multiple properties make up the foreign key then specify an anonymous type including the properties .
cascadeDelete
bool
A value indicating whether or not cascade delete should be configured on the foreign key constraint.
A value indicating whether or not cascade delete should be configured on the foreign key constraint .
name
string
The name of this foreign key constraint. If no name is supplied, a default name will be calculated.
The name of this foreign key constraint . If no name is supplied a default name will be calculated .
anonymousArguments
object
Additional arguments that may be processed by providers. Use anonymous type syntax to specify arguments e.g. 'new { SampleArgument = "MyValue" }'.
Additional arguments that may be processed by providers . Use anonymous type syntax to specify arguments e . g . ' new { SampleArgument = " MyValue " } ' .