わかりません。model.edmxに2つのテーブルがあります。
それから私は私の3つのテーブルを持っています:
CREATE TABLE [Group].[RecommendedUserGroups]
(
[Groups_GroupId] INT NOT NULL,
[RecommendedUsers_RecommendedUserId] int NOT NULL,
CONSTRAINT [PK_GroupRecommendedUser] PRIMARY KEY CLUSTERED ([Groups_GroupId] ASC, [RecommendedUsers_RecommendedUserId] ASC),
CONSTRAINT [FK_RecommendedUsers_RecommendedUserGroups] FOREIGN KEY ([RecommendedUsers_RecommendedUserId]) REFERENCES [Zinc].[RecommendedUsers] ([RecommendedUserId]),
CONSTRAINT [FK_Groups_RecommendedUserGroups] FOREIGN KEY ([Groups_GroupId]) REFERENCES [Group].[Groups] ([GroupId])
)
CREATE TABLE [Group].[Groups]
(
[GroupId] INT NOT NULL IDENTITY(1, 1),
[Customers_CustomerId] INT NOT NULL,
[Name] NVARCHAR(128) NOT NULL,
[IsArchived] BIT NOT NULL,
[SmallImageUrl] NVARCHAR (256) NULL,
[MediumImageUrl] NVARCHAR (256) NULL,
[LargeImageUrl] NVARCHAR (256) NULL,
[AllowFiltering] BIT NOT NULL DEFAULT 0,
[IsSegment] BIT NOT NULL CONSTRAINT DF_Groups_IsSegment DEFAULT 0,
CONSTRAINT [PK_Groups] PRIMARY KEY CLUSTERED ([GroupId] ASC),
CONSTRAINT [FK_Groups_Customers] FOREIGN KEY ([Customers_CustomerId]) REFERENCES [Zinc].[Customers] ([CustomerId]),
)
CREATE TABLE [Zinc].[RecommendedUsers]
(
[RecommendedUserId] INT IDENTITY(1,1) NOT NULL,
[Firstname] NVARCHAR (50) NOT NULL,
[Surname] NVARCHAR (50) NOT NULL,
[Email] NVARCHAR (256) NOT NULL,
[Department] NVARCHAR (256) NULL,
[JobTitle] NVARCHAR (256) NULL,
[DateAndTimeProcessed] DATETIME NULL,
[Users_UserId] INT NOT NULL,
[DateAndTimeRecommended] DATETIME NOT NULL,
[AssignedUserId] INT NULL,
CONSTRAINT [PK_RecommendedUsers] PRIMARY KEY CLUSTERED ([RecommendedUserId] ASC),
)
その後、私のエンティティ:
namespace Zinc.Entities
{
public class RecommendedUser
{
#region Properties
public virtual int RecommendedUserId { get; set; }
public virtual string Firstname { get; set; }
public virtual string Surname { get; set; }
public virtual string Email { get; set; }
public virtual string Department { get; set; }
public virtual string JobTitle { get; set; }
public virtual DateTime? DateAndTimeProcessed { get; set; }
public virtual int Users_UserId { get; set; }
public virtual DateTime? DateAndTimeRecommended { get; set; }
public virtual int AssignedUserId { get; set; }
public virtual ICollection<Group.Group> Groups { get; set; }
#endregion
}
}
namespace Zinc.Entities.Group
{パブリッククラスグループ{#regionプロパティ
public virtual int GroupId { get; set; }
public virtual string Name { get; set; }
public virtual bool IsArchived { get; set; }
public virtual bool IsSegment { get; set; }
public virtual bool AllowFiltering { get; set; }
public virtual string SmallImageUrl { get; set; }
public virtual string MediumImageUrl { get; set; }
public virtual string LargeImageUrl { get; set; }
public virtual Entities.Customer Customer { get; set; }
#endregion
#region ICollections
//i am only concerned with recommended user so will just put this collection here
private ICollection<RecommendedUser> _groupRecommendedUsers;
public virtual ICollection<RecommendedUser> RecommendedUsers
{
get
{
if (_groupRecommendedUsers == null)
_groupRecommendedUsers = new List<RecommendedUser>();
return _groupRecommendedUsers;
}
set
{
_groupRecommendedUsers = value;
}
}
したがって、recommendeユーザーの詳細を含むグループを保存すると、recommendedUserGroupsテーブルに書き込まれますが、RecommendedUserGroupsテーブルは更新されません。
誰か助けてもらえますか?私はmvc3を使用しています