I have 3 tables, but when I create my edmx, it only shows 2 on the edmx model. I also can't access my xref table through navigation. I am able to insert the primary key id from each table into the xref table, but I have no idea how to do modify the xref table since I am not getting any navigation properties and it does not show up in the model. Here are the tables
**Subscription Table**
[Id] [int] IDENTITY(1,1) NOT NULL,
[SubscriptionTypeId] [int] NOT NULL,
[Active] [bit] NULL,
[IsScheduledNotification] [bit] NOT NULL,
[NotificationFrequencyInMinutes] [int] NOT NULL,
[CompanyId] [int] NULL,
CONSTRAINT [PK__Subscription] PRIMARY KEY CLUSTERED
**[Exchange]**
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[Code] [nvarchar](100) NULL,
PRIMARY KEY CLUSTERED
**[SubscriptionExchange] - Xref table**
[SubscriptionId] [int] NOT NULL,
[ExchangeId] [int] NOT NULL,
CONSTRAINT [PK_SubscriptionExchanges] PRIMARY KEY CLUSTERED
(
[SubscriptionId] ASC,
[ExchangeId] ASC
)
So I am using Asp.Net MVC and trying to modify the records. I am currently able to modify the Subcription table but need to modify [SubscriptionExchange] xref table as well.
I already have foreign keys set in the database for SubscriptionExchange table
The problem is when I execute the following code it doesnt take into account updating the SusbcriptionExchange table. The object a below is referring to Subscription table in the database and you would see exchanges collection in the block. I have initialised the collection with the exchange ids. The subscription id is initialised in line one.
Avanade.Bureau.DataAccessLayer.DatabaseModel.Subscription a = new DataAccessLayer.DatabaseModel.Subscription
{
Id = model.SubscriptionId,
SubscriptionTypeId = model.SubscriptionTypeId,
IsScheduledNotification = false,
Active = true,
NotificationFrequencyInMinutes = 104,
Exchanges = GetExchanges(postedExchanges, bureauEntities),
Users = GetUsers(postedUsers, bureauEntities),
CompanyId = model.CompanyId
};
bureauEntities.Entry(a).State = EntityState.Modified;
bureauEntities.Subscriptions.Attach(a);
bureauEntities.SaveChanges();