// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Data.Entity.Infrastructure
{
using System.Data.Entity.Core.Metadata.Edm;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Data.Entity.Utilities;
using System.Linq;
///
/// This convention uses the name of the derived
/// class as the container for the conceptual model built by
/// Code First.
///
public class ModelContainerConvention : IEdmConvention
{
#region Fields and constructors
private readonly string _containerName;
///
/// Initializes a new instance of the class.
///
/// The model container name.
internal ModelContainerConvention(string containerName)
{
DebugCheck.NotEmpty(containerName);
_containerName = containerName;
}
#endregion
#region Convention Apply
///
/// Applies the convention to the given model.
///
/// The model.
public virtual void Apply(EdmModel model)
{
Check.NotNull(model, "model");
model.Containers.Single().Name = _containerName;
}
#endregion
}
}