Reputation: 11
I need to exclude some tables from publishing in a database project, the main idea is to publish only a subset of tables depending on the build configuration, if it's Debug I want to publish all the tables but if the configuration is Release I want to publish just a subset of those tables.
Upvotes: -2
Views: 48
Reputation: 161
Try this code:
[Conditional("RELEASE")]
public static void InsertConditionally(YourDbContext context)
{
context.Database.Migrate();
if( !context.Products.Any())
{
context.Products.AddRange(
new Product("name 1 release", "param 1"),
new Product("name 2 release", "param 1"),
new Product("name 3 release", "param 1")
);
context.SaveChanges();
}
}
[Conditional("DEBUG")]
public static void InsertConditionally(YourDbContext context)
{
context.Database.Migrate();
if (!context.Products.Any())
{
context.Products.AddRange(
new Product("name 1 debug", "param 1"),
new Product("name 2 debug", "param 1"),
new Product("name 3 debug", "param 1")
);
context.SaveChanges();
}
}
Upvotes: 0