-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #1907
- Loading branch information
Showing
4 changed files
with
526 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/EntityFramework.Relational/Migrations/Infrastructure/ModelDifferContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// 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.Collections.Generic; | ||
using JetBrains.Annotations; | ||
using Microsoft.Data.Entity.Metadata; | ||
using Microsoft.Data.Entity.Migrations.Operations; | ||
|
||
namespace Microsoft.Data.Entity.Migrations.Infrastructure | ||
{ | ||
public class ModelDifferContext | ||
{ | ||
private readonly IDictionary<IEntityType, IEntityType> _entityTypeMap = new Dictionary<IEntityType, IEntityType>(); | ||
private readonly IDictionary<IProperty, IProperty> _propertyMap = new Dictionary<IProperty, IProperty>(); | ||
private readonly IDictionary<IEntityType, CreateTableOperation> _createTableOperations = new Dictionary<IEntityType, CreateTableOperation>(); | ||
|
||
public virtual void AddMapping([NotNull] IEntityType source, [NotNull] IEntityType target) | ||
=> _entityTypeMap.Add(source, target); | ||
public virtual void AddMapping([NotNull] IProperty source, [NotNull] IProperty target) | ||
=> _propertyMap.Add(source, target); | ||
public virtual void AddCreate([NotNull] IEntityType target, [NotNull] CreateTableOperation operation) | ||
=> _createTableOperations.Add(target, operation); | ||
|
||
public virtual IEntityType FindTarget([NotNull] IEntityType source) | ||
{ | ||
IEntityType target; | ||
_entityTypeMap.TryGetValue(source, out target); | ||
|
||
return target; | ||
} | ||
|
||
public virtual IProperty FindTarget([NotNull] IProperty source) | ||
{ | ||
IProperty target; | ||
_propertyMap.TryGetValue(source, out target); | ||
|
||
return target; | ||
} | ||
|
||
public virtual CreateTableOperation FindCreate([NotNull] IEntityType target) | ||
{ | ||
CreateTableOperation operation; | ||
_createTableOperations.TryGetValue(target, out operation); | ||
|
||
return operation; | ||
} | ||
} | ||
} |
Oops, something went wrong.