This question is locked. New answers and comments are not allowed.
Hello,
I am creating my schema using code only and I need to create several tables using the same table schema only with a different name. I need to add a variable string for MappingConfiguration ToTable("mystring") method. In other words I need to have ToTable(MyVariable). I am not sure how to
achieve this. The problem is when I call UpdateSchema(), the variable logic is somehow lost when creating the table mapping. Below is an idea of what I am doing.
protected override Telerik.OpenAccess.Metadata.MetadataContainer CreateModel()
{
Telerik.OpenAccess.Metadata.MetadataContainer model = base.CreateModel();
model.DefaultMapping.NullForeignKey = true;
return model;
}
protected override IList<MappingConfiguration> PrepareMapping()
{
List<MappingConfiguration> config = new List<MappingConfiguration>();
MappingConfiguration<Template> template = new MappingConfiguration<Template>();
template.MapType(x => new
{
Id = x.Id,
Name = x.Name,
Value = x.Value
}).ToTable(MyVariable);
template.HasProperty(p => p.Id).IsIdentity();
template.HasProperty(p => p.Name).IsNotNullable().IsUnicode().HasLength(100);
template.HasProperty(p => p.Value).IsNullable().IsUnicode().HasLength(100);
config.Add(template);
return config;
}
}
I am creating my schema using code only and I need to create several tables using the same table schema only with a different name. I need to add a variable string for MappingConfiguration ToTable("mystring") method. In other words I need to have ToTable(MyVariable). I am not sure how to
achieve this. The problem is when I call UpdateSchema(), the variable logic is somehow lost when creating the table mapping. Below is an idea of what I am doing.
protected override Telerik.OpenAccess.Metadata.MetadataContainer CreateModel()
{
Telerik.OpenAccess.Metadata.MetadataContainer model = base.CreateModel();
model.DefaultMapping.NullForeignKey = true;
return model;
}
protected override IList<MappingConfiguration> PrepareMapping()
{
List<MappingConfiguration> config = new List<MappingConfiguration>();
MappingConfiguration<Template> template = new MappingConfiguration<Template>();
template.MapType(x => new
{
Id = x.Id,
Name = x.Name,
Value = x.Value
}).ToTable(MyVariable);
template.HasProperty(p => p.Id).IsIdentity();
template.HasProperty(p => p.Name).IsNotNullable().IsUnicode().HasLength(100);
template.HasProperty(p => p.Value).IsNullable().IsUnicode().HasLength(100);
config.Add(template);
return config;
}
}