I am running into the same exact problem as asked in this question: Entity Framework, Foreign Keys, and EntityKeys where my Foreign ID key values are being reverted back to 0 before I am able to send the information to the database. This results in the error:
The INSERT statement conflicted with
the FOREIGN KEY constraint
"FK_Sel...
If I ran several queries and ObjectContext was populated with entities how do I clear the context if I don't need those entities anymore. I know that I need to dispose the context as soon as possible, but in this case it is not possible. So is there any way that I can remove those objects from the context?
...
Currently im using EF and using its datacontext directly in all of my actions, but since i started reading about loose coupling and testability im thinking that thats not the best way to go. Im trying to understand all the pro's and con's before i start refactor all my current code.
Problem 1:
Considering that every entity needs its own...
Hi,
I am using Entity Framework 4.
I have my model file with my tables on it. If I go and add a new column to one of my tables (in SQL Server) how do I update the table in the model without having to go and delete and re-adding it to the model?
Thanks
...
Tables
Departments
Employees
I'm trying to associate:
Departments - dept_code : char(4)
Employees - dept : varchar(4)
But I receive the following error,
Error 2039: The conceptual side
property 'DEPT_CODE' has already been
mapped to a storage property with type
'char'. If the conceptual side
property is map...
Hi all,
I have a question about Entity Framework. Please answer if you know answer on this. I have such query :
String queryRaw =
"SELECT " +
"p.ProductName AS ProductName " +
"FROM ProductEntities.Products AS p " +
"INNER JOIN CategoryEntities.Categories AS c " +
"ON p.CategoryID = c.CategoryID ";
ObjectQuery<Db...
Hi everybody im trying to add new items to master detail records and i get the error:
The INSERT statement conflicted with the FOREIGN KEY constraint "invOrden_InvOrdenDet_FK1". The conflict occurred in database "InventarioSIAIplus", table "dbo.InvOrden", column 'IDorden'.
The statement has been terminated.
This error Happens when i ad...
I have a WPF application consuming data using Entity Framework 4 and Self-Tracking Entities. In which I have a window with 2 controls in it, one that shows the "Details" portion of an object using a ContentControl and templates from a merged resource dictionary. Another with a ListBox of Groups the object in question belongs to and a Com...
I have a DB stored procedure that returns a float. The Stored proc does calculations of inputs and spits out a "Rating" based in the inputs. I was able to update the Model and perform a function import, but when I try and use the new function in Linq i get the following error.
Function metadata used in
DbFunctionExpression must a...
Hi there,
Is it possible to have "table per type" inheritance in the Entity Framework 4 if the derived table has a composite primary key?
Here is my table setup:
TABLE: ConfigurationKey (Base Entity)
PK: Id
TABLE: ConfigurationKey_Device (Derived Entity)
PK: ConfigurationKeyId (FK to ConfigurationKey.Id)
PK: DeviceId (FK to Device.Id...
Hello Friends,
I am working in ASP.Net MVC 1.0 and SQL Server 2000 using Entity Framework.
My faulty controller code is given below:
int checkUser = id ?? 0;
string userNameFromNew, userNameToNew;
if (checkUser == 1)
{
userNameFromNew = "U" + Request.Form["usernameFrom"];...
Hi,
I'm using entity framework 4.
I have a stored procedure that just updates one value in my table, namely the application state ID. So I created a stored procedure that looks like this:
ALTER PROCEDURE [dbo].[UpdateApplicationState]
(
@ApplicationID INT,
@ApplicationStateID INT
)
AS
BEGIN
UPDATE
[Application]
S...
I'm moving a bunch of code to Entity Framework and I need to represent a many to many link visually. This is done by a list of checkboxes with some of them checked to represent the join table.
I've looked at Dynamic Data and while that works well, I can't see how to extract their ManyToMany_Edit.ascx file and use it in ASP.Net. Another ...
I am having some trouble with refreshing the related collection of entities.
Essentially the problem is as follows:
public class Student
{
public virtual ICollection<Lecture> Lectures { get; set; }
public void AddLecture(Lecture lecture)
{
Lectures.Add(lecture);
}
public void CancelChanges()
{
...
I am working with Entity Framework ... I have a database table for Patient which has a non-enforced foreign key relationship to the Employee table so I can associate a manager to a patient.
I created my entity in EF for the Patient, the Employee and an association between Patient and Employee, which I name to ManagerEmployee.
I also...
According to this article you are suppose to be able to do includes using a lambda expression http://romiller.com/2010/07/14/ef-ctp4-tips-tricks-include-with-lambda/.
For example ...
var blogsWithPosts = context.Blogs.Include(b => b.Posts);
So where I have ...
IQueryable<Data.Patient> query = ctx.ObjectContext.Patients
...
Do you think it could be a good idea to use F# for implementation Business Logic Layer? I am going to use Entity Framework as 'data mapper' and implement UI logic using C#.
Any thought are welcome. I would appreciate any help!
Thanks.
P.S. What is a purpose of that? I am newbie in F# and would like to experiment with that Language (te...
Hey folks,
I've been learning MVC 2 and I have pretty much everything understood except for the model part of things, I understand what the model is but actually implementing it has me confused.
Here's my situation, I have my DB which has 3 tables;
Ideas - table of ideas
Tags - table of tags
IdeaTag - link table connecting the above 2 ...
I am working with a SQL data source that has duplicate data in multiple tables. I have no control over the database. For my project, I've created an EF model and an ADO.NET data service (using VS 2008) that exposes it. I also have a .NET client application that consumes the service.
Now, these db tables have a large number of fields co...
Hi,
I have an existing web application that uses EF and POCO objects. I want to improve the client experience by exposing some of my objects through WCF(JSON). I have this working fine but where I am unsure is how to handle derived objects(not sure if that is the correct term) or IEnumerable anonymous objects if you will.
Let's say I ...