score:0
well, you never actually associate the new act with any gig - is that what is missing?
dbgig.acts.add(dbact);
or maybe:
dbact.gig = dbgig;
or something with the ids.
i.e. are you sure the act in the db is for the gig?
score:0
i had a similar issue, the problem / solution in my case was that the internal class that represented the database table was missing part of the primary key.
this appeared to work ok until the data from the db caused a primary key constraint in the code that the database was happy with.
pt
score:1
an alternative to gfrizzle's answer is unless you have a compelling reason to do so don't call submitchanges until after you have done all the db work.
score:2
try opening a fresh dbcontext at the beginning of this block. if you're using the same context for the first and second run, it won't see the inserted record the second time around. resetting the context should force it to see the latest rows in the table.
Source: stackoverflow.com
Related Query
- Linq and DeleteAllOnSubmit pain
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- LINQ Source Code Available
- Refactor Linq code and "LINQ to Entities does not recognize the method"
- How can I code an outer join using LINQ and EF6?
- C# - Linq optimize code with List and Where clause
- IEqualityComparer and Linq Distinct - Hard Code GetHashCode()
- creating Linq to sqlite dbml from DbLinq source code
- Stubbing Code for Test With Linq Expressions and Lambdas
- SQL subquery result in LINQ and Entity Framework Code First
- Code Rewite for tuple and if else statements by using LINQ
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- Linq To SQL InsertAllOnSubmit and DeleteAllOnSubmit
- source code for LINQ 101 samples
- Linq lazy loading, (EF Code first, Web.API and MVC)
- C# LINQ code for two list compare and replace
- LINQ GroupBy Source = A Destination = B or Source = B and Destination = A
- How to dynamically create linq code at runtime and get results
- Optimise and speed up very slow Linq / SQL code
- How to break link between source collection and LINQ result
- EF Code First and linq extension methods - foreign keys, am i doing it wrong?
- Entity Framework 4 and Linq to Entities specifications: How to code it?
- Implicit operators, Linq and Lambda expressions can make code less readable. But what is more readable?
- c# Linq or code to extract groups from a single list of source data
- how to fetch data from database using linq query for relationship 1:N and N:N (between 3 entity) in asp.net mvc EF code first?
- How to assign LINQ Query to a variable and then use it later in the code
- Linq Find Partial Text Match - Included code returns duplicate and everything except what it should
- Querying the database using EF Code First and Linq
- IEnumerable.Except() on LINQ doesn't run between ideal source and target lists
- How to write SQL translateable linq code that groups by one property and returns distinct list
More Query from same tag
- Copy array with `ToArray` Method
- LINQ to NHibernate, "get by array of ids" query
- How could I use linq when calculating a answer from a symbol and two numbers
- Linq ordering result by number of Null
- LINQ to SQL and LINQ to Entity Join with static AND condition
- Flatten list of dynamic objects in c#
- linq objects grouping
- How do I get the max data size of every column in an IQueryable using LINQ
- Linq order by not ordering
- C# LINQ: How is string("[1, 2, 3]") parsed as an array?
- HtmlAgilityPack - Selecting Multiple Nodes
- Passing a groupfunction to Linq query dynamically
- Entity Framework with LINQ, JOIN and ORDER BY with column in joined table
- Left outer join one-to-one in Entity Framework
- In Linq, which is more efficient, join or include
- Get data from relationship objects in entity framework?
- Order by with Collate clause | Entity Framework
- Entity Framework 6: Include nested nullable many to many children
- Entity Framework 'ArrayIndex' is not supported in LINQ to Entities
- SkipWhile TakeWhile, then take also lines above until a match
- Finding Nodes in list by properties on C#
- LINQ GroupBy - Cannot Implicitly convert type
- Using Dynamic Linq with late bound crm 2015 entities
- IQueryable, how to handle particular cases
- How to get the Intersection of Multiple sets but Ignore Sets that Don't Intersect
- Linq to Sql Foreign key relationships
- Cannot implicitly convert time type System.TimeSpan to 'long'
- This is a linq sanity check
- LINQ Grouping by Sum Value
- Using Linq to get groups from a collection