score:1
actually, after posting my comment i had a bit of a brainwave, which might end up answering your question. this is a theory:
you mentioned your table is defined as follows:
create table groups(
manhom int primary key,
tennhom char(100)
);
that yields an entity, correctly decorated with [key]
attribute:
public partial class group
{
[key]
public int manhom { get; set; }
public string tennhom { get; set; }
}
}
what i suspect happens when you call ef's .savechanges() is it completely ignores the value id manhom
assuming that the db will take care of it. in mysql however, the pk will not auto-increment unless you tell it to. which is where you need to either:
1. update table:
create table groups(
manhom int auto_increment primary key,
tennhom char(100)
);
2. update model:
this so answer provides some guidance:
public partial class group
{
[key]
[databasegenerated(databasegeneratedoption.none)]
public int manhom { get; set; }
public string tennhom { get; set; }
}
}
Source: stackoverflow.com
Related Query
- Can't add a new record with an integer value into database by using linq from code C#
- Using LINQ and a dropdownlist to enter a new record into an SQL Database
- How to get multiple column value from database into a list using LINQ query
- how delete more than one record from database using Linq in asp.net mvc
- I am trying create a new list of users from a list of users who have not created an additional object with a certain property using LINQ
- Is possible with LINQ to extract from an array of objects the value of one property and create a new array?
- Get the objects with the maximum value for a specific property from a list using LINQ
- What's the best way to copy and insert data from related tables into a new set of related tables with Linq
- Using Linq to select into an object with children from Json
- Insert Record into two tables with one to many relation by using linq to ado.net entity froamwork
- Remove multiple keys with same value data from dictionary in C# using Linq
- Using LINQ to select item in List<T> and add integer to populate new List<T>
- Add List objects from a single list to a new List using LINQ
- get new list which contain any numeric value from current list using LINQ query
- Could i mix values from local data with values returned from database while using LINQ to SQL?
- Nullable DateTime from SQL database into Datatable using generics and Linq
- Bind the values without duplicates from database into dropdown using LINQ
- How to get record form a different table based on a value from first table with linq expression?
- Join into with column and variable value compared using Linq or Entity Framework queries
- Cant add data to xml from list using linq
- How to add Timestamp value in SQL database by using LINQ
- Extract value from json in a database column using linq
- How to split a string in a datatable and add into new rows using Linq C#?
- how to get the value member of a selected comboBox to use it to add a new object with linq
- Select top N with record from DataTable with some sorting using Linq
- Using a integer obtained from a database and using it to retrieve some data from database using Linq
- Group rows with identical value into column using LINQ
- Using Linq to group a list of objects into a new grouped list of list of objects with 4 objects in each group
- Is there a possibility to take 100 records then other 100 record from database table using LinQ and Take()
- Remove set of elements from list A and add into list B using Linq
More Query from same tag
- How can I convert DateTime to String in Linq Query?
- How to rewrite EF LINQ query that used to work in .NET Core 2.0 but doesn't in 3.0?
- Count the number of Enum values in list using Linq
- Dynamic Join of multiple entities based on some filter in Entity Framework
- Checking for null on object before trying to access it
- Using filters in linq expression tree
- Getting object using LINQ Min()?
- Put LINQ Query in Method with Property as Parameter
- Difference between DBNull.Value and IsValueNull()
- An Entity Framework expression to find entities that don't match some property
- Linq Expression to execute existing expression on a child property
- cannot convert type decimal to double
- Get database row from selected item in Combobox
- How to convert database results to Dictionary<int, List<decimal>>
- Read from XML > Add to Listview
- Exclude columns where all rows in that column are null or equal to 0 in LINQ
- How can I add two conditional filters to the same IEnumerable?
- Getting last element of an xml file
- Exception message trying to obtain the Window handle of a process
- LINQ thinks I need an extra INNER JOIN, but why?
- C# Custom Linq Provider
- Pull out Comma Seperated String from EntitySet<T>
- LINQ Update query with Join condition
- LINQ - Join with List
- Disposing an IDisposable in Linq
- How to create this query using Entity Framework and Linq
- C# LINQ to Entities - Retrieve all records and position for waiting list records
- What's the underscore.js equivalent to LINQ's SelectMany operator?
- get list from xml using linq based on true if there is no true then select false condition tag element in c#
- LINQ Code-First Select Using Composite Foreign Key