using System;
|
|
using System.Data.Entity;
|
|
using System.Web;
|
|
using Microsoft.AspNet.Identity.EntityFramework;
|
|
|
|
namespace Sevomin.Models
|
|
{
|
|
public class SevominDbContext : IdentityDbContext<User>
|
|
{
|
|
|
|
#region Singleton
|
|
private static object locker = new object();
|
|
|
|
public SevominDbContext() : base("UsersConnectionString") { }
|
|
|
|
public static SevominDbContext Current
|
|
{
|
|
get
|
|
{
|
|
lock (locker)
|
|
{
|
|
if (HttpContext.Current.Items["DataContexMember"] != null &&
|
|
HttpContext.Current.Items["DataContexMember"] is SevominDbContext)
|
|
return (SevominDbContext)HttpContext.Current.Items["DataContexMember"];
|
|
RenewMember();
|
|
return (SevominDbContext)HttpContext.Current.Items["DataContexMember"];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public static void RenewMember()
|
|
{
|
|
SevominDbContext pe =
|
|
new SevominDbContext();
|
|
HttpContext.Current.Items["DataContexMember"] = pe;
|
|
GC.Collect();
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
public DbSet<Parameter> Parameters { get; set; }
|
|
public DbSet<ParameterValue> ParameterValues { get; set; }
|
|
}
|
|
}
|