Hi,
I am an experienced .NET developer but new to EF - so please bear with me. I will use an example of a college application to illustrate my problem. I have these user roles:
Lecturer, Student, Administrator.
In my code I envisage working with these entities as distinct classes so e.g. a Lecturer teaches a collection of Students. An...
Say I have the following table definitions in SQL Server 2008:
CREATE TABLE Person
(PersonId INT IDENTITY NOT NULL PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
ManyMoreIrrelevantColumns VARCHAR(MAX) NOT NULL)
CREATE TABLE Model
(ModelId INT IDENTITY NOT NULL PRIMARY KEY,
ModelName VARCHAR(50) NOT NULL,
Description VARCHAR(200) NULL)
CR...
If I have a static method like this
private static bool TicArticleExists(string supplierIdent)
{
using (TicDatabaseEntities db = new TicDatabaseEntities())
{
if((from a in db.Articles where a.SupplierArticleID.Equals(supplierIdent) select a).Count() > 0)
return true;
...
I have a many-to-many relationship:
Application ->
Applications_Servers ->
Server
This is set up in my Entity Data Model and all is well. My problem is that I'd like to eager-load the whole graph of Applications so that I have an IEnumerable<Applications>, each Application member populated with the Servers collection associated by the...
I have a project using Entity Framework 4.0 with POCOs (data is stored in SQL DB, lazyloading is enabled) as follows:
public class ParentObject {
public int ID {get; set;}
public virtual List<ChildObject> children {get; set;}
}
public class ChildObject {
public int ID {get; set;}
public int ChildRoleID {get; set;}
p...
I need to quickly build a report. In VS 2010 when I'm adding new item in the 'Reporting' brach there are 3 items:
Report Wizard;
Report;
and
Crystal Report
I tried to play with the first one - couldn't find a way to get the data through existing entity model. Also I stupidly confused what's the real difference between 'Report' ...
Given following ASP.NET MVC controller code:
[HttpPost]
public ActionResult Create(FormCollection collection)
{
string[] whitelist = new []{ "CompanyName", "Address1", "Address2", ... };
Partner newPartner = new Partner();
if (TryUpdateModel(newPartner, whitelist, collection))
{ ...
Stepping away more and more from writing SQL for my applications, I decided to give the Entity Framework a try. However, I've run into something I believe is causing me to write more code than I think is strictly necessary.
When I accessed some navigational properties, I discovered that all many-to-one relations (simple references) were...
I asked a question about this previously but my database structure has changed, and while it made other things simpler, now this part is more complicated. Here is the previous question.
At the time, my EF Context had a UsersProjects object because there were other properties. Now that I've simplified that table, it is just the keys, s...
I´m trying out entity framework included in VS2010 but ´ve hit a problem with my database/model generated from the graphical interface.
When I do:
user = dataset.UserSet.CreateObject();
user.Id = Guid.NewGuid();
dataset.UserSet.AddObject(user);
dataset.SaveChanges();
{"Cannot insert the value NULL into column 'Id', table 'BarSoc2.dbo...
I know this same question was asked for Entity Framework 1, but now that Entity Framework 4 has come out, and Microsoft claims that it provides all of the features of Linq to Sql + more, does Entity Framework now support lazy loading expensive properties? In Linq to Sql, this is extremely easy. There's a Delay Loaded option on any prop...
I am building a WPF 4.0 Application using MVVM. The Model is generated using Entity Framework 4.0.
I am using Data binding on the WPF to bind the user input to model properties.
What is the easiest way to validate user input ?
I prefer an approach where I can set the validation rules on the Model rather than on the WPF itself. How can t...
Hi,
In .NET land what would be a good approach for quick prototyping of a concept (i.e. development just on my PC) that could then be extended out to product (users across LAN/WAN), BUT in a fashion that the model/business logic code and data access layer code can be used as is?
One thought for example I had as to do:
(a) WinForms with...
hi, someone can tell me how to do this query in EF1:
select a.idAnimali, a.titolo, a.commenti, a.ordine, a.idcatanimali, table1.nomefoto FROM tabanimali as a LEFT JOIN
(SELECT idanimali, nomefoto tabfotoanimali FROM LIMIT 1) AS Table1
On a.idAnimali = table1.idanimali
WHERE a.idcatanimali = idcatanimale
Thanks
...
I have a view which has an Int column which is nullable (let's call it StackOverflowCount). When generating an EF model from the database, the EF designer does not recognise it as nullable and creates the column as an Int.
The issue I have is that on the EF designer I have set the column to Nullable and the following error then kills th...
Okay, this is really weird. I made a simple database with a single table, Customer, which has a single column, Name. From the database I auto-generated an ADO.NET Entity Data Model, and I'm trying to add a new Customer to it like so:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
...
In separate data access & business logic layer, can I use Entity framework classes in business layer?
EDIT: I don't think I will need to swap out the data access layer from my business logic in the future (i.e. will be SQL Server), however I will for the UI layer. Therefore the question is more meant to be are there any major issues wi...
Hi,
I'm interested in having a look at a small sample project that would highlight a good technique to separate data access layer (using Entity Framework) to business logic layer. In C# would be good.
That is, it would highlight how to pass data between the layer without coupling them. That is, the assumption here is not to use the E...
Hi,
Actually I am getting an exception "Conflicting changes to the role 'TableName' of the relationship 'DataModel.FK_TableName_RelateTableName' detected" when ApplyChanges method is called from the ObjectContext. I dont have any idea what this exception is all about. I just wanted to know the cause of this exception.
Thanks,
Burhan G...
Is there an equivalent of nhibernate's DistinctRootEntity transformer in EF 4.0?
Cheers
...