Questions tagged [entitykey]
15 questions
7
votes
3 answers
Entity Framework EntityKey / Foreign Key problem
As the result of a form post, I'm trying to save a new Brand record. In my view, Gender is a dropdown, returning an Integer, which is populated from ViewData("gender")
I've setup my link as follows:
gID =…

Squiggs.
- 4,299
- 6
- 49
- 89
4
votes
4 answers
How to get first EntityKey Name for an Entity in EF4
How can I get the 1st EntityKey name for an Entity for Entity Framework 4 because I'm building a repository system and I wanted to get an item by Id (which is the primary key oin EF is the 1st entitykey for the entity)
I'm using this code
public…

Ahmed Magdy
- 5,956
- 8
- 43
- 75
2
votes
1 answer
How to get the value of EntityKey?
How to get the value of EntityKey?
I tried:
String x = Customer.EntityKey.EntityKeyValues[0].Value;
String x = Customer.EntityKey.EntityKeyValues[0].Value.ToString();
String x = Customer.EntityKey.EntityKeyValues;
String x =…

noobplusplus
- 177
- 1
- 2
- 12
2
votes
0 answers
Entity Framework Insert Error When 2 EntityKeys Being Used
Following is a sample of the error I'm getting. The code names and such have been changed to make it more readible and it has been 'dumbed down' to just show the parts I'm having trouble with.
TABLE STRUCTURE:
SUMMARY
I'm trying to add a new CHILD…

Adam
- 379
- 2
- 15
1
vote
2 answers
Why does Entity Framework make certain fields EnityKeys when they are not even PK's in the source DB?
Starting out on an Entity Framework project.
Imported the Db I am going to use and right away noticed that many table fields were made into EntityKey types and the source fields are not even Keys. Doesn't seem to be a pattern as to which fields…

user259286
- 977
- 3
- 18
- 38
1
vote
1 answer
Set EntityKey manually without accessing the database
In my application (database-first) the primary keys are always created by client, not by the underlying database.
In Entity Framework v4 each Entity had it's EntityKey property that could be set manually.
However, I can't find it anymore in EF6?
Is…

KingKerosin
- 3,639
- 4
- 38
- 77
1
vote
2 answers
SqlQuery EntityKey and return corresponding object
I would like to query my database based on a EntityKey is there a inbuild (or easier approach) to do this?
My current approach, would be something like this:
using (var context = new DbContext())
{
context.DataBase.SqlQuery("select *…

Rand Random
- 7,300
- 10
- 40
- 88
1
vote
2 answers
EntityReference has an EntityKey property value that does not match?
I am attempting to add some entities that I have created. When I try and add the entity in question to the set (see code below) I get the following error:
"The object could not be added or attached because its EntityReference has an EntityKey…

Graham Conzett
- 8,344
- 11
- 55
- 94
1
vote
1 answer
ASP.net MVC: Where in my design should I create/declare entity keys?
When creating a new entity object that has a foreign key value I need to create a new Entity key (Entity Framework in .net 3.5) for the object, but I'm having trouble deciding where in my application I should do this.
Right now when I create a new…

Graham Conzett
- 8,344
- 11
- 55
- 94
0
votes
2 answers
When the EntityKey create and when it disposed
I create a new object and want to attach it to a context like this,
User user = new User();
user.userName=”Kobe”;
context.Attach(user);
An error message appears – “An object with a null EntityKey value cannot be attached to an object context”.
If I…

James
- 2,570
- 7
- 34
- 57
0
votes
1 answer
Linq to Entities - Reference EntityKey
Now that I have built a database.
Visual Studio 2008 SP1’s ADO.NET Entity Framework has generated an Entity Model like this:
http://img835.imageshack.us/img835/1810/carease15test1ef.png
I have created a method as follow:
private void…

Priere Law
- 113
- 1
- 9
0
votes
1 answer
Multi-table insert fails on EntityKey property
I am trying to update 2 tables: RESTAURANT and HOURS. The tables shere the REST_ID key. I get an error on the line with the arrow (==>): Sorry, I'm trying to teach myself this stuff and it's the first time I've tried a multi-table insert.
The…

Susan
- 1,822
- 8
- 47
- 69
0
votes
1 answer
Accessing foreign key value (int) in Entity Framework
I just spent the last 3-4 hours trying to retrieve a foreign key value using linq to entities and a stored procedure. Any advice is much appreciated.
public JsonResult GetEvents(double? start, double? end)
{
AnoEntities _dbAno = new…

Derek Hunziker
- 12,996
- 4
- 57
- 105
0
votes
1 answer
How to tell Breeze which property is the Entity Key
If I have a POCO-Object (nothing to do with EF or any other Framework), and it looks like the following (from NoDb-Example):
public class TodoItem {
public int TodoItemId { get; set; }
public string Title { get; set; }
public bool IsDone {…

NoRyb
- 1,472
- 1
- 14
- 35
0
votes
1 answer
Temporary EntityKey not generated
I am creating a new EntityObject that do not exist in the database (SQLite). I populate the object's properties and join it to parent object. I am not populating the primary key property because as I understand EF should automatically generate a…

Nuts
- 2,755
- 6
- 33
- 78