I am getting started with Entity Framework 4, using model-first development. I am building a simple WPF demo app to learn the framework. My app has two entities, Topic and Note. A Topic is a discussion topic; it has Title, Text, and DateRevised properties. Topic also has a Notes collection property. a Note has DateCreated and Text proper...
Hi,
I have a table of Plants and Information.
Plants have an ID, Name, ..., MainInformationID
Information have an ID, Title, ..., PlantID
One plant can have many information, but only one MainInformation. Information can only have one plant.
I have a class ViewModel which contains observable collections of plants and information whi...
It seems to me that I have to retrieve an object before I delete it with entity framework like below
var customer = context.Customers.First(c => c.Id = 1);
context.DeleteObject(customer);
context.Savechanges();
So I need to hit database twice. Is there a easier way?
Thanks
...
I write the following code with entity framework
context.AddObject(obj1);
context.AddObject(obj2);
context.DeleteObject(obj3);
context.SaveChanges();
The last command issue multiple sql command in separate branches, it seems to be is not efficient at all, is there a option to send all command in a single batch?
Thanks
...
Hello,
Currently my website is based around MVC and the Entity Framework running against a SQL Server 2005 database. So far, it has all been running very smoothly, and I really enjoy MVC and its slimmer more concise code (and no huge viewstates or soul destroying postbacks ;))
Recently I was working on upgrading the site to use a simpl...
I have an Entity Data Model that I have created, and its pulling in records from a SQLite DB.
One of the Tables is People, I want to override the person.Equals() method but I'm unsure where to go to make such a change since the Person object is auto-generated and I don't even see where that autogen code resides. I know how to override Eq...
I am creating an EF4 model-first application with a WPF UI. One of the controls on my UI is a RichTextDocument, which outputs a WPF FlowDocument. I can either serialize the FlowDocument to a byte array, or extract its XAML markup as a string. I would prefer to use binary serialization, if I can. Here are my questions:
If I serialize t...
I was using .mdf for connect to DB and entityClient. Now i want to change connection string that trehe will be no .mdf
Is this conectionstring correct
<connectionStrings>
<!--<add name="conString" connectionString="metadata=res://*/conString.csdl|res://*/conString.ssdl|res://*/conString.msl;provider=System.Data.SqlClient;provider conne...
I would like to model the following many to many relationship.
Table A
ID
Field1
Field2
Table B
ID
Field1
Field2
LinkTable
A_ID
B_ID
Field_I_want_to_ignore
As I understand it, if LinkTable.Field_I_want_to_ignore was not present, the Entity Model Designer would automatically create a Many to Many relationship between entity A and ent...
I have a SQLite DB that is set up so when I delete a Person the delete is cascaded. This works fine when I manually delete a Person (all records that reference the PersonID are deleted). But when I use Entity Framework to delete the Person I get an error:
System.InvalidOperationException: The operation failed: The relationship could no...
Hi,
I've been programming for a while and have used LINQ-To-SQL and LINQ-To-Entities before (although when using entities it has been on a Entity/Table 1-1 relationship - ie not much different than L2SQL)
I've been doing a lot of reading about Inversion of Control, Unit of Work, POCO and repository patterns and would like to use this m...
I have this linq query:
var segreterie = from s in db.USR_Utenti join h in db.USR_Accounts
on new {s.ID, settings.GruppoSegreteria}
equals new {h.USR_UtentiReference,h.ID_Gruppo} select s;
that has this problem:
The type of one of the expressions in the join clause is incorrect. Type infere...
The selector expression for LoadProperty must be a MemberAccess for the property.
I'm converting some C# to VB, this is the C# line:
entities.LoadProperty((MyType)MyTargetObject, c => c.MyProperty);
I convert it to VB like so:
entities.LoadProperty(DirectCast(MyTargetObject, MyType), Function(c) c.MyProperty)
However I get the err...
Ok, this may sound a little 'unorthodox', but...using VS2010 and the new POCO t4 template for Entity Framework (http://tinyurl.com/y8wnkt2), I can generate nice POCO's. I can then use these POCO's (as DTO's) in a WCF service essentially going from EDM all the way through to the client. Kinda what this guys is doing (http://tinyurl.com/yb...
I am creating a model-first Entity Framework 4 app that uses SQL CE as its data store. All is well until I call ObjectContext.SaveChanges() to save changes to the entities in the model. At that point, SaveChanges() throws a System.Data.UpdateException, with an inner exception message that reads as follows:
Server-generated keys and serv...
I have run into my first dissapointment with Entity Framework 4. It turns out that SQL CE, when used with EF4, does not support autogenerated primary keys. I get a System.Data.UpdateException from OnjectContext.SaveChanges() with this message:
Server-generated keys and server-generated values are not supported by SQL Server Compact.
So...
Hello,
I have been searching the blogs and articles but I have not found much support for this scenario. I have been poking around EF and realized that I could create views that contained data from multiple databases and then build the EF object model off of those views. Although it works I am not sure about the usual issues of performa...
Is there a simple way to view the machine generated SQL for SaveChanges() on an Entity Framework context?
...
I am using Entity Framework and I've come to an interesting stumbling block. Let's say there is a db table "Item" with "sequence" column of type int (and others of course). Column "sequence" must be unique and it is used for (re)ordering of items.
EF maps this table to "Item" class with "sequence" int property. Now let's say I want to s...
This is a follow-up to an earlier question I posted on EF4 entity keys with SQL Compact. SQL Compact doesn't allow server-generated identity keys, so I am left with creating my own keys as objects are added to the ObjectContext. My first choice would be an integer key, and the previous answer linked to a blog post that shows an extension...