Browse Source

dbcontext change

confirmation-email
uJ 11 years ago
parent
commit
1bd2a9e432
10 changed files with 273 additions and 14 deletions
  1. +1
    -1
      Sevomin.Models/Helpers/SevominUserValidator.cs
  2. +29
    -0
      Sevomin.Models/Migrations/201403280733264_Param values.Designer.cs
  3. +47
    -0
      Sevomin.Models/Migrations/201403280733264_Param values.cs
  4. +126
    -0
      Sevomin.Models/Migrations/201403280733264_Param values.resx
  5. +2
    -2
      Sevomin.Models/Migrations/Configuration.cs
  6. +11
    -1
      Sevomin.Models/Parameter.cs
  7. +7
    -6
      Sevomin.Models/ParameterValue.cs
  8. +8
    -0
      Sevomin.Models/Sevomin.Models.csproj
  9. +41
    -3
      Sevomin.Models/UsersDbContext.cs
  10. +1
    -1
      Sevomin.WebFrontend.Controllers/AccountController.cs

+ 1
- 1
Sevomin.Models/Helpers/SevominUserValidator.cs View File

@ -14,7 +14,7 @@ namespace Sevomin.Models.Helpers
public SevominUserValidator() public SevominUserValidator()
{ {
manager = new UserManager<User>(new UserStore<User>(new UsersDbContext()));
manager = new UserManager<User>(new UserStore<User>(SevominDbContext.Current));
} }
public async Task<IdentityResult> ValidateAsync(User item) public async Task<IdentityResult> ValidateAsync(User item)


+ 29
- 0
Sevomin.Models/Migrations/201403280733264_Param values.Designer.cs View File

@ -0,0 +1,29 @@
// <auto-generated />
namespace Sevomin.Models.Migrations
{
using System.CodeDom.Compiler;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
[GeneratedCode("EntityFramework.Migrations", "6.1.0-30225")]
public sealed partial class Paramvalues : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(Paramvalues));
string IMigrationMetadata.Id
{
get { return "201403280733264_Param values"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}

+ 47
- 0
Sevomin.Models/Migrations/201403280733264_Param values.cs View File

@ -0,0 +1,47 @@
namespace Sevomin.Models.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class Paramvalues : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.Parameters",
c => new
{
Id = c.Int(nullable: false, identity: true),
Name = c.String(nullable: false),
Moscow = c.Boolean(nullable: false),
DisplayMethod = c.Byte(nullable: false),
GroupName = c.String(nullable: false),
CommentAvalin = c.String(maxLength: 140),
CommentDovomin = c.String(maxLength: 140),
ParameterValueId = c.String(maxLength: 50),
})
.PrimaryKey(t => t.Id)
.Index(t=>t.ParameterValueId);
CreateTable(
"dbo.ParameterValues",
c => new
{
GroupKey = c.String(nullable: false, maxLength: 50),
Value = c.String(nullable: false, maxLength: 50),
})
.PrimaryKey(t => new { t.GroupKey, t.Value })
.Index(t => t.GroupKey);
}
public override void Down()
{
DropForeignKey("dbo.ParameterValues", "Parameter_Id", "dbo.Parameters");
DropIndex("dbo.ParameterValues", new[] { "Parameter_Id" });
DropIndex("dbo.ParameterValues", new[] { "GroupKey" });
DropTable("dbo.ParameterValues");
DropTable("dbo.Parameters");
}
}
}

+ 126
- 0
Sevomin.Models/Migrations/201403280733264_Param values.resx View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Target" xml:space="preserve">
<value>H4sIAAAAAAAEAN1d227kuBF9D5B/EPS0G3i7fVkPJoa9C0/b3hgZXzDtWeTNoCV2WxhdeiXKYyPIl+Uhn5RfCKkrrxIpqaV2sMCsLZKnisUiWUUWy//9939Of30NfOsFxokXhWf2wWzftmDoRK4Xrs/sFK1++mj/+suf/3R66Qav1u9lvSNSD7cMkzP7GaHNyXyeOM8wAMks8Jw4SqIVmjlRMAduND/c3//r/OBgDjGEjbEs6/RLGiIvgNkv+NdFFDpwg1Lg30Qu9JPiOy5ZZqjWLQhgsgEOPLOX8CUKvHCW17Stc98DCfnsr2wLhGGEAMI8nnxN4BLFUbhebvAH4D+8bSCutwJ+AgveT+rqut3YPyTdmNcNSygnTVAUGAIeHBVymfPNO0nXruSGJXeJJYzeSK8z6Z3Z9y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migrations/Configuration.cs View File

@ -5,7 +5,7 @@ namespace Sevomin.Models.Migrations
using System.Data.Entity.Migrations; using System.Data.Entity.Migrations;
using System.Linq; using System.Linq;
internal sealed class Configuration : DbMigrationsConfiguration<Sevomin.Models.UsersDbContext>
internal sealed class Configuration : DbMigrationsConfiguration<Sevomin.Models.SevominDbContext>
{ {
public Configuration() public Configuration()
{ {
@ -13,7 +13,7 @@ namespace Sevomin.Models.Migrations
ContextKey = "Sevomin.Models.UsersDbContext"; ContextKey = "Sevomin.Models.UsersDbContext";
} }
protected override void Seed(Sevomin.Models.UsersDbContext context)
protected override void Seed(Sevomin.Models.SevominDbContext context)
{ {
// This method will be called after migrating to the latest version. // This method will be called after migrating to the latest version.


+ 11
- 1
Sevomin.Models/Parameter.cs View File

@ -33,6 +33,16 @@ namespace Sevomin.Models
[StringLength(140)] [StringLength(140)]
public string CommentDovomin { get; set; } public string CommentDovomin { get; set; }
[StringLength(50)]
public string ParameterValueId { get; set; }
[NotMapped]
public ICollection<ParameterValue> ParameterValues
{
get
{
return SevominDbContext.Current.ParameterValues.Where(x => x.GroupKey == ParameterValueId).ToList();
}
}
} }
} }

+ 7
- 6
Sevomin.Models/ParameterValue.cs View File

@ -10,16 +10,17 @@ namespace Sevomin.Models
{ {
public class ParameterValue public class ParameterValue
{ {
[Key]
public int Id { get; set; }
[Required] [Required]
[Index] [Index]
[Index("IX_UniqueKey", 1, IsUnique=true)]
public int GroupKey { get; set; }
[Key]
[Column(Order=1)]
[StringLength(50)]
public string GroupKey { get; set; }
[Required] [Required]
[Index("IX_UniqueKey", 2, IsUnique = true)]
[Key]
[Column(Order = 2)]
[StringLength(50)]
public string Value { get; set; } public string Value { get; set; }
} }
} }

+ 8
- 0
Sevomin.Models/Sevomin.Models.csproj View File

@ -49,6 +49,7 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.0.0\lib\net45\System.Web.Mvc.dll</HintPath> <HintPath>..\packages\Microsoft.AspNet.Mvc.5.0.0\lib\net45\System.Web.Mvc.dll</HintPath>
@ -81,6 +82,10 @@
<Compile Include="Migrations\201403270733330_Avvalin-update.Designer.cs"> <Compile Include="Migrations\201403270733330_Avvalin-update.Designer.cs">
<DependentUpon>201403270733330_Avvalin-update.cs</DependentUpon> <DependentUpon>201403270733330_Avvalin-update.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Migrations\201403280733264_Param values.cs" />
<Compile Include="Migrations\201403280733264_Param values.Designer.cs">
<DependentUpon>201403280733264_Param values.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" /> <Compile Include="Migrations\Configuration.cs" />
<Compile Include="Parameter.cs" /> <Compile Include="Parameter.cs" />
<Compile Include="ParameterValue.cs" /> <Compile Include="ParameterValue.cs" />
@ -107,6 +112,9 @@
<EmbeddedResource Include="Migrations\201403270733330_Avvalin-update.resx"> <EmbeddedResource Include="Migrations\201403270733330_Avvalin-update.resx">
<DependentUpon>201403270733330_Avvalin-update.cs</DependentUpon> <DependentUpon>201403270733330_Avvalin-update.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Migrations\201403280733264_Param values.resx">
<DependentUpon>201403280733264_Param values.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.


+ 41
- 3
Sevomin.Models/UsersDbContext.cs View File

@ -1,9 +1,47 @@
using Microsoft.AspNet.Identity.EntityFramework;
using System;
using System.Data.Entity;
using System.Web;
using Microsoft.AspNet.Identity.EntityFramework;
namespace Sevomin.Models namespace Sevomin.Models
{ {
public class UsersDbContext : IdentityDbContext<User>
public class SevominDbContext : IdentityDbContext<User>
{ {
public UsersDbContext() : base("UsersConnectionString") { }
#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; }
} }
} }

+ 1
- 1
Sevomin.WebFrontend.Controllers/AccountController.cs View File

@ -12,7 +12,7 @@ namespace Sevomin.WebFrontend.Controllers
public class AccountController : BaseController public class AccountController : BaseController
{ {
public AccountController() public AccountController()
: this(new UserManager<User>(new UserStore<User>(new UsersDbContext())))
: this(new UserManager<User>(new UserStore<User>(SevominDbContext.Current)))
{ {
} }


Loading…
Cancel
Save