All my entities has property Id. All my tables in database has auto-generated integer identity Id as primary key.
I have generic method to Create entities.
Is there any way to get entity Id after entity inserted in to database?
public override int Create<T>(T entity)
{
string entitySet = GetEntitySetName<T>();
_...
Ok obviously I am fighting .net here ... and the answer is probably that i am barking up the wrong tree and should just get on with just using the kind of database design i would of 5 years ago.
What I want is to have an abstract object Client and have 2 inherited objects Supplier and Customer.
The relationship between client and both ...
I have 2 classes: User and Booklink
public class User
{
public int UserID { get; set; }
public string Email { get; set; }
public string Login { get; set; }
public string Surname { get; set; }
public string Name { get; set; }
public int Points { get; set...
So I have a model in my domain similar to this:
public class Product
{
public virtual Tag Methodology { get; set; }
}
Then in an webform project I update it like so:
if (!string.IsNullOrWhiteSpace(ddlMethodology.SelectedValue))
product.Methodology = TagRepo.GetTagById(int.Parse(ddlMethodology.SelectedValue));
else
product...
I am using EF 4 Feature CTP 4.
I have the following database schema:
[Users] 1-M [UserRoles] M-1 [Roles]
I have a User and Role class (both POCOs).
When I try to associate an existing role to a user, a new record is getting inserted in the Roles table, instead of only inserting a new record in UserRoles.
So say I have User 1 and wa...
I created a "Code Only" POCO for use against an existing database using Entity Framework 4 and the CTP4. When I run a query I get the error
The model backing the 'xyzContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer inst...
I have an sqlce 3.5 local db file in my VS2010 solution used with an EF4 Model. I need to protect my db with a password but do not serialize it in app.config. I also need to set up the maximum database file size to it's maximum allowed value which is 4091 MB
when I try to set the connectionString in code, I can't find a way to set the 'M...
I have two "Code Only" POCO's using EF4 and the latest CTP, running against an existing, legacy database. Running a LINQ query against PocoA worked until I added a public virtual PocoB pocoB { get; set; } to PocoA. I was trying to add a relationship.
Once I did that, I started getting the following error:
Multiple object sets per typ...
Hello,
I am using VS2010, Entity Framework 4.0, and Advantage v. 10 in my application. I have written a Linq-to-Entities (L2E) statement that tries to convert a nullable numeric (decimal) type to a decimal. A simple statement might look like:
var x = (from test in entities.Tests
select test.ValueA.HasValue ? test.ValueA.Valu...
Hello,
I am using VS2010, Entity Framework 4.0, and Advantage v. 10 in my application. I am trying to make a UDF I have defined in my Advantage DB available to my application code. The designer does not show the UDF under stored procs in the "Update Model from Database" wizard as I would expect it to. So I manually added the UDF to t...
Hi All, I have a entity model and on it i have a object with name Person that this object
have 1 ti 1 relation with NaturalPerson and LegalPerson.
therefore the Person is a abstract class and Naturalperson and LegalPerson inherited from Person, but when i try to add NaturalPerson in DAL i got this error
A referential integrity constrain...
My program (WCF service programed in C#) has to access multiple sql server groups and the databases within those groups (sql server). It looks like linq 2 sql definitely doesn't support this unless I create multiple dataclasses per database, and it looks like the entity framework is in the same boat.
How would you go about setting up yo...
Hi All,
I have been working away for EF4 and got a lot of stuff done and its working really nicely, the one problem I do have is: Context.CreateQuery returns correctly, but it is also loading ALL its related entities too!?
Which is going to cause massive issues once the DB actually has real data in there.
Any ideas on how to stop it ...
Hi, I'm using SQLCE database and Entity Framework 4 as my Data Access in a Winforms project.
Create a class library to store all my Queries, Inserts, Updates, Deletes. I want to work in a disconnected environment without change tracking or contexts loaded, so i use code like this
for a query (example):
public List<UserPlaylists> GetUse...
I have such stored proc in my db which doing this:
UPDATE SomeTable
SET SomeId = SomeNewId
WHERE Id IN
(
SELECT TOP 100 Id
WHERE Id IN
(
SELECT Id FROM SomeTable WHERE SomeColumn IS NOT NULL
)
)
SELECT @@Rowcount AS 'RowCount'
I did i...
Is there a way in Entity Framework 4 (using CTP4 and Code First if that matters) to change the conventions used to automatically identify primary and foreign keys? I'm trying to use EF with a legacy database that uses a "pk/fk" prefix rather than an "id" suffix to mark keys. Also, it's not uncommon to have multiple foreign keys to an A...
Hi, I'm trying out EF4 as part of a .Net 4.0 WCF service. The aim of the service is to return document data as an array of entity objects to any of our ASP.Net apps. The apps are still in .Net 2.0. Due to the nature of the solution I've disabled LazyLoading at context level. I started with this:
var revQuery = from revs in context.t...
I need a solution on detaching an Entity and his child records from a context.
If i try to detach the parent entity only from a List<> i queried with LINQ to Entities
i lose the child records. If i try to enumerate through the child records and detach them i get an InvalidOperationException.
Is there a solution i miss?
...
Is it possible to map following POCO class with EF 4.0?
public class MyClass
{
private string _myData;
public MyClass()
{ }
public MyClass(string myData)
{
_myData = myData;
}
public string MyData
{
get
{
return _myData;
}
}
}
In NHibernate I think it is possible when I use Access attribute ...
Here is my simplest structure
Customer
CustomerID
FirstName
LastName
...
BrokerID <- Navigation Property created with this FK
Broker
BrokerID
FirstName
LastName
Now my question is, if I load multiple customers, and I want to see list of customer and I also need to see the Name of Broker associated with the cus...