All Questions
Tagged with identity-column entity-framework
19 questions
3
votes
3
answers
6k
views
Entity Framework Core attempting to update column marked as Identity in model
I have a database table where one of the columns is an IDENTITY column (not the primary key which is set manually). My EF Core model looks like this:
public class Model
{
[Key]
[...
0
votes
1
answer
70
views
EF Required to Optional Relationship not using the right columns for FK
I already read many questions, but still couldn't find a solution to my problem.
I am trying to have something like this I drawed very quickly
First Try:
public class CarMap : ...
0
votes
1
answer
49
views
Check whether entity column is autoincrement
I need to identify whether the dbcontext column is AutoIncrement column.
i.e: db.events, event_id column is AutoIncrement?
1
vote
2
answers
1k
views
Is it possible to auto increment a property which is not the primary key in Entity Framework?
Is it possible to have a primary key and another field which is not the primary key with the "auto increment" function in Entity Framework?
I found this on the web, tried it, but it does not work:
...
0
votes
1
answer
46
views
get identity when adding via entity framework
I'm using entity framework to insert a new record into my templates database. I would like to know what the identity of the inserted record is after the insert is done.
my code for inserting the ...
2
votes
2
answers
752
views
Get Identity Field out of KeyMembers
I would like to get the KeyMembers where I have set in the Edmx the StoreGeneratedPattern to Identity is there a way to do this?
I can get the KeyMembers with this code:
private static IEnumerable&...
0
votes
2
answers
1k
views
Data insert issue after migrating database from SQL Azure to SQL Server
I have a database on SQL Azure which has an identity primary.
After using SQL Server Import and Export Wizard, I transferred the data to my SQL Server 2008 R2 database.
My ASP.NET Application runs ...
4
votes
1
answer
779
views
Exponentially deteriorating performance on inserts in SQL Server Compact 4.0 tables with an Identity column
EDIT: the issue below has been fixed in the Entity Framework 6.
Running the code below takes a disappointing 2 minutes and 10 seconds. Running it a second time takes 6.5 minutes. This question is ...
2
votes
3
answers
875
views
Is using a (sequential) GUID the only viable alternative to a database generated ID?
We are migrating our MS-Access database to SQL Server Compact 4.0 using the Entity Framework 5 Code First approach. We found that using Database generated Integer ID's is very slow and to make it ...
0
votes
1
answer
106
views
Strategy for implementing a composite key of which the second part is rarely discriminating. Entity Framework Code First
I have the following scenario:
An Atom Entity is usually unique and can be stored in the database using a single AtomID field as its primary key.. In rare cases theAtomneeds to be split. In that ...
0
votes
3
answers
450
views
Letting EF 4.1 auto-create an identity column
Suppose you have
public class A
{
public string _myString;
}
And this context:
public class MyContext: DbContext
{
public DbSet<A> myASet{ get; set; }
}
Now, is there a way to tell EF ...
1
vote
2
answers
9k
views
ExecuteStoreCommand returns -1 , EntityFramework , C#?
I wanna get the next automatically incrementing primary key, Here I understood to use T-SQL for doing that.
So I wrote the following method :
public int GetLastNewsID()
{
const string command = @...
4
votes
2
answers
3k
views
EF returns 0000-0000-0000-xxx as Guid when I try save a new record or update existing record?
I am using EF4 in my C# project. The problem I'm faced with is that, when I try to save a record, I get a Primary Key Violation and the PK value is "0000-0000-0000-xxx". From my guess, EF does not ...
10
votes
7
answers
30k
views
In Entity Framework, getting the value of an identity column after inserting
I'm using EF4. I want to insert a new MyObject into the database. MyObject has two fields:
Id: int (Identity) and
Name: string
As I've seen in documentation Entity Framework is supposed to set ...
1
vote
1
answer
444
views
How should I handle maintaining row Identity for new records in Linq / Entity Framework?
What is the proper way to create a new unique shared key when using Linq and EF with SQL?
I could use a GUID upon inserting the record but I only want want my keys to have 7 digits or characters in ...