Files
cms_thermo_active/Step.Database/Migrations/Configuration.cs
T

36 lines
1.8 KiB
C#

namespace Step.Database.Migrations
{
using Step.Model.DatabaseModels;
using System.Data.Entity.Migrations;
using static Step.Utils.Constants;
public sealed class Configuration : DbMigrationsConfiguration<DatabaseContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
AutomaticMigrationDataLossAllowed = true;
ContextKey = "Step.Database.DatabaseContext";
}
protected override void Seed(DatabaseContext context)
{
// This method will be called after migrating to the latest version.
context.Roles.AddOrUpdate(
new RoleModel() { RoleId = 1, Level = 10, Name = "Admin" },
new RoleModel() { RoleId = 2, Level = 0, Name = "Guest" }
);
context.FunctionsAccess.AddOrUpdate(
// General Function
new FunctionAccessModel() { FunctionAccessId = 1, Name = "general", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 100, ReadLevelMin = 1, PlcId = -1 },
new FunctionAccessModel() { FunctionAccessId = 2, Name = "userFunctions", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = -1 },
new FunctionAccessModel() { FunctionAccessId = 3, Name = "ncData", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 10, ReadLevelMin = 1, PlcId = -1 },
new FunctionAccessModel() { FunctionAccessId = 4, Name = "startupIcons", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = 0 },
new FunctionAccessModel() { FunctionAccessId = 5, Name = "alarmCmd", Area = AREAS.GENERAL_KEY, Enabled = true, WriteLevelMin = 1, ReadLevelMin = 1, PlcId = 1 }
);
context.SaveChanges();
}
}
}