-
-
Save M-Zuber/807661a410a88a326b5adfa7c6eb0430 to your computer and use it in GitHub Desktop.
EntityTypeConfiguration issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CouponActionMap : EntityTypeConfiguration<CouponAction> | |
{ | |
public CouponActionMap() | |
{ | |
ToTable("CouponAction"); | |
} | |
} | |
public class CouponMap : EntityTypeConfiguration<Coupon> | |
{ | |
public CouponMap() | |
{ | |
ToTable("Coupon"); | |
HasRequired(c => c.Action); | |
} | |
} | |
public class DiscountSchemeActionMap : EntityTypeConfiguration<DiscountSchemeAction> | |
{ | |
public DiscountSchemeActionMap() | |
{ | |
ToTable("DiscountSchemeAction"); | |
} | |
} | |
public class DiscountSchemeMap : EntityTypeConfiguration<DiscountScheme> | |
{ | |
public DiscountSchemeMap() | |
{ | |
ToTable("DiscountScheme"); | |
HasRequired(ds => ds.Action); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum CouponFormula | |
{ | |
} | |
public class CouponAction | |
{ | |
public int Id { get; set; } | |
public int CouponId { get; set; } | |
public CouponFormula Formula { get; set; } | |
public string Fields { get; set; } | |
public virtual Coupon Coupon { get; set; } | |
} | |
public enum CouponUsage | |
{ | |
PerPerson, | |
PerOrder | |
} | |
public class Coupon | |
{ | |
public int Id { get; set; } | |
public bool GlobalMembershipRequired { get; set; } | |
public bool ProgramMembershipRequired { get; set; } | |
public ProgramType ProgramTypeRequired { get; set; } | |
public string Code { get; set; } | |
public DateTime? StartDate { get; set; } | |
public DateTime? EndDate { get; set; } | |
public int? Limit { get; set; } | |
public int Used { get; set; } | |
public CouponUsage Usage { get; set; } | |
public virtual CouponAction Action { get; set; } | |
} | |
public enum DiscountSchemeFormula | |
{ | |
} | |
public class DiscountSchemeAction | |
{ | |
public int Id { get; set; } | |
public int DiscountSchemeId { get; set; } | |
public DiscountSchemeFormula Formula { get; set; } | |
public string Fields { get; set; } | |
public virtual DiscountScheme DiscountScheme { get; set; } | |
} | |
public enum ApplySchemeScheme | |
{ | |
All, | |
Any | |
} | |
public class DiscountScheme | |
{ | |
public int Id { get; set; } | |
public string Name { get; set; } | |
public ApplySchemeScheme ApplyScheme { get; set; } | |
public virtual DiscountSchemeAction Action { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Coupon | |
SELECT | |
[Project1].[Id] AS [Id], | |
[Project1].[MembershipPlanId] AS [MembershipPlanId], | |
[Project1].[EventId] AS [EventId], | |
[Project1].[GlobalMembershipRequired] AS [GlobalMembershipRequired], | |
[Project1].[ProgramMembershipRequired] AS [ProgramMembershipRequired], | |
[Project1].[ProgramTypeRequired] AS [ProgramTypeRequired], | |
[Project1].[Code] AS [Code], | |
[Project1].[StartDate] AS [StartDate], | |
[Project1].[EndDate] AS [EndDate], | |
[Project1].[Limit] AS [Limit], | |
[Project1].[Used] AS [Used], | |
[Project1].[Usage] AS [Usage], | |
[Project1].[DateCreated] AS [DateCreated], | |
[Project1].[DateUpdated] AS [DateUpdated], | |
[Project1].[Id1] AS [Id1], | |
[Project1].[CouponId] AS [CouponId], | |
[Project1].[Formula] AS [Formula], | |
[Project1].[Fields] AS [Fields], | |
[Project1].[DateCreated2] AS [DateCreated2], | |
[Project1].[DateUpdated2] AS [DateUpdated2] | |
FROM ( SELECT | |
[Extent1].[Id] AS [Id], | |
[Extent1].[MembershipPlanId] AS [MembershipPlanId], | |
[Extent1].[EventId] AS [EventId], | |
[Extent1].[GlobalMembershipRequired] AS [GlobalMembershipRequired], | |
[Extent1].[ProgramMembershipRequired] AS [ProgramMembershipRequired], | |
[Extent1].[ProgramTypeRequired] AS [ProgramTypeRequired], | |
[Extent1].[Code] AS [Code], | |
[Extent1].[StartDate] AS [StartDate], | |
[Extent1].[EndDate] AS [EndDate], | |
[Extent1].[Limit] AS [Limit], | |
[Extent1].[Used] AS [Used], | |
[Extent1].[Usage] AS [Usage], | |
[Extent1].[DateCreated] AS [DateCreated], | |
[Extent1].[DateUpdated] AS [DateUpdated], | |
[Extent3].[Id] AS [Id1], | |
[Extent3].[CouponId] AS [CouponId], | |
[Extent3].[Formula] AS [Formula], | |
[Extent3].[Fields] AS [Fields], | |
[Extent3].[DateCreated] AS [DateCreated2], | |
[Extent3].[DateUpdated] AS [DateUpdated2] | |
FROM [dbo].[Coupon] AS [Extent1] | |
INNER JOIN [dbo].[CouponAction] AS [Extent3] ON [Extent1].[Id] = [Extent3].[Id] | |
) AS [Project1] | |
ORDER BY [Project1].[Id] ASC, [Project1].[Id1] ASC | |
-- Coupon Action | |
SELECT | |
[Extent1].[Id] AS [Id], | |
[Extent1].[CouponId] AS [CouponId], | |
[Extent1].[Formula] AS [Formula], | |
[Extent1].[Fields] AS [Fields], | |
[Extent1].[DateCreated] AS [DateCreated], | |
[Extent1].[DateUpdated] AS [DateUpdated], | |
[Extent2].[Id] AS [Id1], | |
[Extent2].[MembershipPlanId] AS [MembershipPlanId], | |
[Extent2].[EventId] AS [EventId], | |
[Extent2].[GlobalMembershipRequired] AS [GlobalMembershipRequired], | |
[Extent2].[ProgramMembershipRequired] AS [ProgramMembershipRequired], | |
[Extent2].[ProgramTypeRequired] AS [ProgramTypeRequired], | |
[Extent2].[Code] AS [Code], | |
[Extent2].[StartDate] AS [StartDate], | |
[Extent2].[EndDate] AS [EndDate], | |
[Extent2].[Limit] AS [Limit], | |
[Extent2].[Used] AS [Used], | |
[Extent2].[Usage] AS [Usage], | |
[Extent2].[DateCreated] AS [DateCreated1], | |
[Extent2].[DateUpdated] AS [DateUpdated1] | |
FROM [dbo].[CouponAction] AS [Extent1] | |
LEFT OUTER JOIN [dbo].[Coupon] AS [Extent2] ON [Extent1].[Id] = [Extent2].[Id] | |
-- Discount Scheme | |
SELECT | |
[Project1].[Id] AS [Id], | |
[Project1].[MembershipPlanId] AS [MembershipPlanId], | |
[Project1].[EventId] AS [EventId], | |
[Project1].[Name] AS [Name], | |
[Project1].[ApplyScheme] AS [ApplyScheme], | |
[Project1].[DateCreated] AS [DateCreated], | |
[Project1].[DateUpdated] AS [DateUpdated], | |
[Project1].[Id1] AS [Id1], | |
[Project1].[DiscountSchemeId] AS [DiscountSchemeId], | |
[Project1].[Formula] AS [Formula], | |
[Project1].[Fields] AS [Fields], | |
[Project1].[DateCreated2] AS [DateCreated2], | |
[Project1].[DateUpdated2] AS [DateUpdated2] | |
FROM ( SELECT | |
[Extent1].[Id] AS [Id], | |
[Extent1].[MembershipPlanId] AS [MembershipPlanId], | |
[Extent1].[EventId] AS [EventId], | |
[Extent1].[Name] AS [Name], | |
[Extent1].[ApplyScheme] AS [ApplyScheme], | |
[Extent1].[DateCreated] AS [DateCreated], | |
[Extent1].[DateUpdated] AS [DateUpdated], | |
[Extent3].[Id] AS [Id1], | |
[Extent3].[DiscountSchemeId] AS [DiscountSchemeId], | |
[Extent3].[Formula] AS [Formula], | |
[Extent3].[Fields] AS [Fields], | |
[Extent3].[DateCreated] AS [DateCreated2], | |
[Extent3].[DateUpdated] AS [DateUpdated2] | |
FROM [dbo].[DiscountScheme] AS [Extent1] | |
INNER JOIN [dbo].[DiscountSchemeAction] AS [Extent3] ON [Extent1].[Id] = [Extent3].[Id] | |
) AS [Project1] | |
ORDER BY [Project1].[Id] ASC, [Project1].[Id1] ASC | |
-- Discount Scheme | |
SELECT | |
[Extent1].[Id] AS [Id], | |
[Extent1].[DiscountSchemeId] AS [DiscountSchemeId], | |
[Extent1].[Formula] AS [Formula], | |
[Extent1].[Fields] AS [Fields], | |
[Extent1].[DateCreated] AS [DateCreated], | |
[Extent1].[DateUpdated] AS [DateUpdated], | |
[Extent2].[Id] AS [Id1], | |
[Extent2].[MembershipPlanId] AS [MembershipPlanId], | |
[Extent2].[EventId] AS [EventId], | |
[Extent2].[Name] AS [Name], | |
[Extent2].[ApplyScheme] AS [ApplyScheme], | |
[Extent2].[DateCreated] AS [DateCreated1], | |
[Extent2].[DateUpdated] AS [DateUpdated1] | |
FROM [dbo].[DiscountSchemeAction] AS [Extent1] | |
LEFT OUTER JOIN [dbo].[DiscountScheme] AS [Extent2] ON [Extent1].[Id] = [Extent2].[Id] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE [dbo].[Coupon] | |
( | |
[Id] [int] NOT NULL IDENTITY(1, 1), | |
[Name] [nvarchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | |
[Code] [nvarchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | |
[GlobalMembershipRequired] [bit] NOT NULL, | |
[ProgramMembershipRequired] [bit] NOT NULL, | |
[ProgramTypeRequired] [int] NOT NULL CONSTRAINT [DF_Coupon_ProgramTypeRequired] DEFAULT ((0)), | |
[StartDate] [datetime] NULL, | |
[EndDate] [datetime] NULL, | |
[Limit] [int] NULL, | |
[Used] [int] NOT NULL CONSTRAINT [DF_Coupon_Used] DEFAULT ((0)), | |
[Usage] [int] NOT NULL CONSTRAINT [DF_Coupon_Usage] DEFAULT ((0)), | |
[DateCreated] [datetime] NOT NULL CONSTRAINT [DF_Coupon_DateCreated] DEFAULT (getdate()), | |
[DateUpdated] [datetime] NULL | |
) ON [PRIMARY] | |
GO | |
ALTER TABLE [dbo].[Coupon] ADD CONSTRAINT [PK_Coupon] PRIMARY KEY CLUSTERED ([Id]) ON [PRIMARY] | |
GO | |
CREATE TABLE [dbo].[CouponAction] | |
( | |
[Id] [int] NOT NULL IDENTITY(1, 1), | |
[CouponId] [int] NOT NULL, | |
[Formula] [int] NOT NULL, | |
[Fields] [nvarchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | |
[DateCreated] [datetime] NOT NULL CONSTRAINT [DF_CouponAction_DateCreated] DEFAULT (getdate()), | |
[DateUpdated] [datetime] NULL | |
) ON [PRIMARY] | |
GO | |
ALTER TABLE [dbo].[CouponAction] ADD CONSTRAINT [PK_CouponAction] PRIMARY KEY CLUSTERED ([Id]) ON [PRIMARY] | |
GO | |
ALTER TABLE [dbo].[CouponAction] ADD CONSTRAINT [FK_CouponAction_Coupon] FOREIGN KEY ([CouponId]) REFERENCES [dbo].[Coupon] ([Id]) | |
GO | |
CREATE TABLE [dbo].[DiscountScheme] | |
( | |
[Id] [int] NOT NULL IDENTITY(1, 1), | |
[Name] [nvarchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | |
[ApplyScheme] [int] NOT NULL, | |
[DateCreated] [datetime] NOT NULL CONSTRAINT [DF_DiscountScheme_DateCreated] DEFAULT (getdate()), | |
[DateUpdated] [datetime] NULL | |
) ON [PRIMARY] | |
GO | |
ALTER TABLE [dbo].[DiscountScheme] ADD CONSTRAINT [PK_DiscountScheme] PRIMARY KEY CLUSTERED ([Id]) ON [PRIMARY] | |
GO | |
CREATE TABLE [dbo].[DiscountSchemeAction] | |
( | |
[Id] [int] NOT NULL IDENTITY(1, 1), | |
[DiscountSchemeId] [int] NOT NULL, | |
[Formula] [int] NOT NULL, | |
[Fields] [nvarchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, | |
[DateCreated] [datetime] NOT NULL CONSTRAINT [DF_DiscountSchemeAction_DateCreated] DEFAULT (getdate()), | |
[DateUpdated] [datetime] NULL | |
) ON [PRIMARY] | |
GO | |
ALTER TABLE [dbo].[DiscountSchemeAction] ADD CONSTRAINT [PK_DiscountSchemeAction] PRIMARY KEY CLUSTERED ([Id]) ON [PRIMARY] | |
GO | |
ALTER TABLE [dbo].[DiscountSchemeAction] ADD CONSTRAINT [FK_DiscountSchemeAction_DiscountScheme] FOREIGN KEY ([DiscountSchemeId]) REFERENCES [dbo].[DiscountScheme] ([Id]) | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment