I'm trying to update an entity using a stub. This works fine for changing records, unless I try to set the value back to the default value forr the column. Eg: If the default value is 0, I can change to and from any value except zero, but the changes aren't saved if I try to set it back to zero. This is the code I'm using:
var package =...
Our product is partially built using Delphi and partially .NET and in our current state of migration to .NET, we have the data dictionary in a Delphi component, so this is the master.
From this we generate .NET source code through templating, to support simple querying but also to do Linq2Sql, since our product requires SQL Server.
How...
I have an ASP.NET Dynamic Data application (using Entity Framework) in which I have just discovered a duplicate key error when attempting a database insert. However, I had to use SQL Profiler to find the error. The insert template page just silently did nothing.
How can I trap errors like this and log them and maybe display a message?...
I need to be able to do
select * from myTable with (xlock,holdlock)
from Entity Framework. Is this possible? I've opened a TransactionScope with the Serializable isolation level but my selects are not locking the tables. I'd like them to lock until I complete the transaction scope.
...
First a little about myself. I am not an experienced software engineer, architect or developer. I have done mostly small ASP and ASP.NET projects in C# for the last 5 years. I am pretty good with HTML and JavaScript. These projects were done when I had free time from my other duties which were not related to software development. I have ...
I am not very sure what design pattern is the most efficent to use when working with ASP.Net MVC and the Entity Framework, so any guidance is much appreciated!
Would you store the context in the Controller-class, or is it better to create a repository?
If you would recommend the repo-design, is it required to initialize the context in ...
Someone has an answer to this missing feature in Entity Framework. Does anyone have a solution to the missing Contains method in Entity Framework that works? I've tried a number of those on here and through Google, but none of them seem to actually work.
...
I am trying to create entities out of a SQLite database. SQLite doesnt have foreign keys, therefore I cannot map associations between entities. Is there a way to map them somehow?
...
Hey Guys,
How to connect to different databases for a .NET MVC web application written in C#?
Here the stucture of the database table remains the same. All that changes is the database name. So how to I manually connect to a database or use modify the connection string?
The trick is to use the same code. Depending on the URL I want th...
I know the method below isn't meant to work with any Entity, and its use shouldn't be enforced.
I found a System.Data.Linq.Table extension method which uses SqlBulkCopy to insert data. I am trying to adapt it to the Entity Framework but it throws a strange exception, while the original works for Linq-To-Sql data classes. I couldn't find...
How do I have to set up a property so that when using SaveChanges, the many to one relationship is saved and I don't get the: INSERT statement conflicted with the FOREIGN KEY constraint... error.
Pretty simple, I have an Ad and an AdType where there are many Ads to one AdType. There is a property on Ad:
public class Ad
{
public I...
I want to use stub entities but it seems I cannot use TryGetObjectStateEntry without the full entity? Is there a way to do this with stub entities or any other way to detect if an entity is already attached? AttachTo will throw a InvalidOperationException if I try to attach the same entity twice. I am trying to save a hit to the database...
A lot has been talked about Entity Framework first version on the web (also on stackoverflow) and it is clear that it was not a good choice when we already have better alternative like NHibernate. But I can't find a good comparison of Entity Framework 4 and NHibernate. We can say that today NHibernate is the leader among all .NET ORMs, b...
What is the process I should follow to update my entity framework model when I have simply added a new column to a table in the database? The process that I have followed was to right click within the edmx file and choose "Update Model from Database". Now I can see the new field against the table definition in the Store. But when I l...
I am converting a project from another ORM to Entity Framework. I have a table where all 3 fields are foreign keys. So this table has been automatically mapped as an Association Set. In the previous ORM I could still work with this table as an entity - writing linq statements against it, adding and deleting objects etc. Is it possibl...
Dim myEmployee as Employee = myObjectContext.Employee.Where("it.EmployeeID = 1").First()
The following line will cause e.EntityState to equal EntityState.Modified :
myEmployee.Name = "John"
However, changing a property that is a relationship will leave e.EntityState = EntityState.Unchanged. For example:
myEmployee.Department =...
Hi
I looked at lot of examples online using Repository Pattern with EF. But none of them really talked about working with Related Entities.
Like say User can have multiple addresses.
IUserRepository
User CreateUser();
void UpdateUser();
Now if I were to add a Address to the User should, should it be on the Repository? OR
on the Use...
Hi
Is it possible to materialize (within the Entity Framework) Entities from a standard SQL Data Reader?
I am writing specific SQL that is passed to the server using EntityConnection.StoreConnection. Thsi returns a standard Data Reader containing rows should be materialized as Entities.
I suppose one workaround is to create a Entity-r...
Hello
I'm having a char(4) FK reltionship, and it gives me lots of errors when I use that in my designer.
I have a relation between tables: BookingObjects 1:* IntervalEntities, and it is a char(4) PK in the IntervalEntities table.
Error 9 Error 3007: Problem in Mapping Fragments starting at lines 813, 1037: Non-Primary-Key column(...
I'm trying to figure out how to limit my child dataset to only include active records...
// Here's what I have currently...
m_BackLoggerEntities.Stories
.Include("Sprints")
.Include("Tasks")
.Include("Efforts")
.Include("Products")
.First(s => s.StoryId == id);
// Here's what I thought I could do.....