/// <summary>
        ///
        /// </summary>
        internal void Apply(ModelBuilder builder)
        {
            foreach (var entity in builder.Model.GetEntityTypes())
            {
                if (!entity.IsOwned())
                {
                    entity.SetTableName(ProcessTableName(entity));
                }

                foreach (var prop in entity.GetProperties())
                {
                    if (entity.IsOwned() && prop.IsPrimaryKey())
                    {
                        continue;
                    }

                    prop.SetColumnName(ProcessColumnName(prop));
                }

                foreach (var key in entity.GetKeys())
                {
                    key.SetName(KeyNamingConvention.Convert(key.GetName()));
                }


                foreach (var index in entity.GetIndexes())
                {
                    index.SetName(IndexNamingConvention.Convert(index.GetName()));
                }
            }
        }
Ejemplo n.º 2
0
            public void Override([NotNull] AutoMapping <User> mapping)
            {
                Fail.IfArgumentNull(mapping, nameof(mapping));

                mapping.Schema(SampleDatabase.SchemaName);

                mapping.Map(u => u.Email)
                .Length(Map.EmailLength)
                .Index(IndexNamingConvention.GetIndexName <User>(u => u.Email))
                .UniqueKey("UQ_Email");

                mapping.HasManyBidirectional(user => user.Groups, group => group.Owner);
            }