DataSource Controls :: Uniqueidentifiers And Entity Framework?

Feb 16, 2010

I have a sql server database that includes the field ArticleID of type uniqueidentifier that is a primary key and is set to be auto-generated by the database when a new article is added.If i generate my entity model and do the following code:

[Code]....

Then a new article is saved to the database but the entity framework must be generating a new blank Guid and saving that to the database rather than allowing it to be auto generated as the articleid that shows up saved is all 0.How can i get the Entity Framework to let the Database generate the ArticleId?

View 3 Replies


Similar Messages:

Visually Set Controls Datasource From Entity Framework?

Feb 27, 2011

I set up Entity Framework for my Table and Stored Procedure to return data. Created a Domain Class as well.

In Domain Class, I am returning Objects as collection.

On .Aspnet page when I drop a Control(Combo,Dropdown) I can set up the source for the controls visually if the source is table.

However, In domain class I have stored precedure object that return collection of data And I cant not set up visually from Designer, I am only available to write code behind. is it possibble that i can set up from desingner.

View 6 Replies

DataSource Controls :: WEB Services And Entity Framework?

Jan 19, 2010

CAN we use Entity framework in web services.I the following error while the code connects to the database using entity framework

View 3 Replies

DataSource Controls :: How To Use A Stored Procedure In Entity FrameWork

Mar 22, 2010

i joined together more than one entity: Customer, Personel etc. i used inner join structures. if i look adonet entity framework ,5 entities are generated. i need to run this SP in C# side:

[Code]....

LOOK BELOW PİC : you can understand it :

MY C# codes: [Code]....

How can i get all joined data from sql with using randevu.GetRandevular(customerID

View 1 Replies

DataSource Controls :: Entity Framework Deleting Many To Many Relationship?

Jul 9, 2010

I have 3 tables User, role and UserInRole THe entity frame work made entities for User and Role and I have successfully made a join with the user and role entities using user.add(role); but I can't seem to get it to remove the link (I want to retain the user and role just remove their association).

using (ProviderEntities context = new ProviderEntities())
{
User u = context.User
.Where(n => n.ApplicationName == application)
.Where(n => n.Username == username).First();
Roles r = context.Roles
.Where(n => n.ApplicationName == application)
.Where(n => n.RoleName == roleName)
.First();
r.User.Remove(u);
context.SaveChanges();
}

The oposite worked when I did r.User.Add(u); but it wont let me now remove it after it been created. Driving me mad as I can't see where I have gone wrong.

View 1 Replies

DataSource Controls :: Use Database Instead Of MDF File With Entity Framework?

Jan 11, 2010

I transfered my data from MDF files to MS SQL Database, but I can't get it working with entity framework.

My Old connection string is:

metadata=res://*/Models.EntityModel.csdl|res://*/Models.EntityModel.ssdl|res://*/Models.EntityModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|TripsDB.mdf;Integrated Security=True;User
Instance=True;MultipleActiveResultSets=True"

I put all data from TripsDB.mdf to Trips table in local MS SQL 2008 Enterprise database. Also changed connection string to:

Server=WIESIEK;Database=Trips;Trusted_Connection=True;providerName=System.Data.SqlClient;User ID=Jan J. Roman

But my application throws System.ArgumentExceptio with message: The 'server' keyword is not supported.

on line:

private TripsDBEntities2 _entity = new TripsDBEntities2();where TripsDBEntities2 is Entity Framework instance.

View 2 Replies

DataSource Controls :: Stored Procedure In Entity Framework?

Jul 7, 2010

I have a stored procedure that generates a float value. I've added the stored procedure to my edmx file and created a function import, but the function isn't showing up in the object browser or via intellisense.

I'm using Visual Studio 2010 and I've verified that the stored procedure works in SSMS. Here is the current stored proc I'm using:

[Code]....

View 1 Replies

DataSource Controls :: Entity Framework EntityKey (Defaults To 0?)

Feb 6, 2010

CarType
Id - PK
Name
CarDetail
Id - PK
TypeId - FK to CarType

I have this simple example here and I want to insert a new CarDetail into the database but for some reason I cannot get the EntityKey to work in EF4 and Framework4 beta 2.

If i declare the following

car_detail.CarTypeReference.EntityKey = new System.Data.EntityKey("MyDB.CarType", "Id", 1)

Each time i try to call SaveChanges, it throws a INSERT constraint error saying that there is a conflict between CarType and CarDetail with the FK. It just seems like the hard coded 1 for CarType is NOT being passed through but instead the default value of 0. What is going on?

If i call car_detail.TypeId = 1 then it works fine with the INSERT.

Why doesn't the EntityKey method work?

View 1 Replies

DataSource Controls :: Left Join With Entity Framework?

May 17, 2010

how to do this query in EF1:

[Code]....

View 3 Replies

DataSource Controls :: Viewing Fields From Two Tables Using Entity Framework

Mar 17, 2010

I have created a .edmx for the northwind database. When I run the following statement, the correct number of detail records are retrieved and I can access the detail fields, but how do I access the order header record to view OrderDate, ShipAddress, etc...?

[Code]....

View 1 Replies

DataSource Controls :: How To Save Multiple Rows Using ADO.NET Entity Framework

Mar 23, 2010

public void saveOptionalCourses( ArrayList coursesAdded, int studentID)
{
StudentOptionalCoursesXRef XRefObject = new StudentOptionalCoursesXRef();
using (var EntityObject = new SchoolProjectEntities2())
{
foreach ( string list in coursesAdded)
{
XRefObject.StudentDetails = EntityObject.StudentDetails.Where(c => c.StudentID == studentID).First();
XRefObject.OptionalCourses = EntityObject.OptionalCourses.Where(c => c.OptionalCourseName == list).FirstOrDefault();
EntityObject.AddToStudentOptionalCoursesXRef(XRefObject);
}
EntityObject.SaveChanges();
}

with this above method and could save only last row that am returning remaining rows are iterated but are not saving on to database

View 2 Replies

DataSource Controls :: How To Insert A Null Into A Record Entity Framework

Feb 24, 2010

I'm using the linq to entity command to perform a record update. I want to set one of the fields back to NULL but I'm not sure how do it. I have a query such as

Dim record = From r in db.LISTS where r.ID = refID Select r
record.Title = txtTitle.text
if txtDetail.text = "" then
record.Detail =
end if

View 3 Replies

DataSource Controls :: Entity Framework - Parent And Child Relationships?

Feb 4, 2010

I am just getting started with entity framework with asp.net 3.5 using VS 2008

There are two tables, Categories & Subcategories:

Category table: CID, CategoryName Sub Category table: SID, CID, SubCategoryName I would like to get SID, CID, CategoryName, SubCategoryName in the gridview. Just as we write a select statement i.eSelect a.sid, b.cid, b.categoryname, b.subcategoryname from subcategories a inner join categories b on a.cid=b.cid & put the same in a gridview.

I was trying for the whole day & couldnt get atleast one url that would teach how to do it.

View 3 Replies

DataSource Controls :: Entity Framework And Architecture Of Model - Create Application Using EF

Feb 10, 2010

I can't to understand clearly how to create strong and quickly application using EF. For example, I have class ForumPost (table ForumPost) for select one of record I write method like:

public ForumPost ForumPost(int ForumPostID)
{
return
(from i in _dataContext.ForumPostSet
where i.ForumPostID == ForumPostID select i).First();
}

all works. But on page (I use ASP.NET MVC) I should display info from another linked tables, ForumName (each post have ForumID) etc. So, I modify this method to:

public ForumPost ForumPost(int ForumPostID)
{
return
(from i in _dataContext.ForumPostSet
.Include("ChildPosts").Include("ParentPost").Include("Users").Include("Forums").Include("Tags").Include("ForumPostPolls")
where i.ForumPostID == ForumPostID select i).First();
}

ok, all works. Then I want to make some actions in model with ForumPost, i.e.

public void RootPost(int PostID, ref Models.ForumPost Root)
{
ForumPost post = ForumPost(PostID);
if (post.RootPost != null)
{
Root = ForumPost(post.RootPost.ForumPostID);
}
else
Root = post;
}

it works too. But problem is in speed. I not need in RootPost all those includes. So, I should to create one more method like:

private ForumPost ForumPostIncludes1(int ForumPostID)
{
return
(from i in _dataContext.ForumPostSet
.Include("ChildPosts")
where i.ForumPostID == ForumPostID
select i).First();
}

then ForumPostIncludes2, ForumPostIncludes3 etc... second way - redesign RootPost with LINQ expr, not with call another method. But in this way difficulties to change DB. third way? How to do it correctly?

View 1 Replies

DataSource Controls :: Best Way To Handle Inserts For Entities When Using FormViews And Entity Framework 4?

Mar 3, 2010

I am trying to get some guidance with this issue:

I have a Customer object that has two address ID fields (one for HomeAddress and one for WorkAddress)

I am loading the Address Objects by using Include="HomeAddress, WorkAddress" and then binding to the properties using the Navigation Property on the Customer Entity

Can I use just one FormView for doing the Insert/Updates and binding it to an EntityDataSource or would I have to do all the Inserting/Updating manually?

View 1 Replies

DataSource Controls :: Entity Framework - Send The Values To Be Inserted As Strings To The DAL?

Feb 5, 2010

I've sucefully created a method to insert values through EF, but i've a question (maybe, a newbie question).

Should i send the values to be inserted as strings to the DAL, and then i create the object there or should i create the object in View Layer and then send him to DAL?

Example 1 (DAL):

[Code]....

Example 1 (View Layer, on a click button for example):

[Code]....

Or should i receive the strings in DAL like this: public bool NoticiasInsert(string tituloPT, string tituloEN, string descricaoPT, string descricaoEN)

Then i create the object cdcModel.noticias and set the fields there with the strings values.

What do you advice me to do? I know that both ways works, but i'm trying to develope with better patterns (i don't know if this is the exacly word, sorry my bad english)

cdcModel.noticias campos = new cdcModel.noticias();
campos.tituloPT = "a";
campos.tituloEN = "b";
campos.descricaoPT = "a";
campos.descricaoEN = "a";
if (DAL.NoticiasInsert(campos)

View 1 Replies

DataSource Controls :: Unable To Select And Insert Data In Mapping Table Using Entity Framework

Jan 18, 2010

I have three table like above, table C is mapping table which has foreign key of Table A and B.How can i select and insert data in Table C using Entity Frame Work?

View 2 Replies

DataSource Controls :: Foreign Key Reference Not Updating With ADO.NET Entity Framework Silverlight/Data Service

Apr 8, 2010

I'm trying to insert a new EF object containing a reference to a related table via foreign key, and cannot get the reference stored in the new object. I have two tables in a SQL Server 2008 Database:

Component Templates
PartGroups

with a Foreign Key linking them thus: ComponentTemplates:ID [0..1<->*] PartGroups:ComponentTemplateID

I have imported these tables into a .NET web application project .edmx file (using a new ADO.NET Entity Data Model), and then created a Data Service which I then reference in a Silverlight 3.0 project. The objects are available as expected in the data context called by my Silverlight app and load correctly. Now, when I try to save a reference of ComponentTemplate into a newly created PartGroup, the PartGroup object is created in the database, but the value of ComponentTemplateID in the newly created table record is NULL.

[Code]....

(Note that _ctCtrl.ComponentTemplate is a confirmed non-NULL object reference to the parent object on which PartGroup is a child)

View 2 Replies

DataSource Controls :: How To Create A Self Association Relation For An Organization Chart Data Tree In Entity Framework

Mar 6, 2010

I,am trying to create a self association relation for an organization chart data tree in Entity Framework,after trying different ways for prevention of exceptions like 3007 and etc. I found that when I put my foreign key in my POCO near Parent and Items navigation properties its work.but I think this is not correct that we have both ParentID scalar property and Parent navigation property. review this and tell me is it correct or not.I'm using VS 2010 RC and ofcource .net framework 4.0 RC

[Code]....

View 2 Replies

Exporting Entity Framework 4 Data Model To Entity Framework 3.5?

Oct 25, 2010

Is there a way to export a EF 4.0 Data Model to EF 3.5?

I looked around and found that we are not able to access EF 4.0 from a ASP.Net 3.5 project here: [URL]

Our project is the 1st to go to .Net 4.0 using Entity Framework and we (the team) were wondering if there was a way for the other projects that "might" need to access our data that are still using the .Net 3.5 framework.

View 1 Replies

ADO.NET :: Entity Framework With Stored Procedure Versus Entity Framework Without Stored Procedures

Nov 2, 2010

I am new to entity framework , it is really very good , but I want to know what is the difference between using entity framework with stored procedure or without stored procedure , which one the faster and what is the benefits for using stored procedures with entity framework.

View 1 Replies

Entity Framework -Update Entity When Another Entity Is Updated

Jun 30, 2010

I have an EDM, it includes the entities extension and history. My goal is to use history to keep track of all the changes made to extension entity. For example, if extension with ID 223 has its property 'Name_Display' changed - I want the history entity to record this.

I'm using ASP.NET with VB.NET. Where in my code do I put the hook to say, "update the history entity" and what should that hook look like?

View 1 Replies

Cast Exception When Try To Insert Entity In Entity Framework (using Code-f)

Feb 9, 2011

I get an cast exception when i am trying to insert an entity in Entity Framework (using code-first). From this code :

public virtual T Insert(T entity)
{
return Context.Set<T>().Add(entity);
}

The cast exception is like "impossible to cast ...Collection'1(Entity) to type (Entity)" I can't figure out why. I am pretty sure ive done everything right. Post entity

public class Post
{
public long PostId { get; private set; }
public DateTime date { get; set; }
[Required]
public string Subject { get; set; }
public User User { get; set; }
public Category Category { get; set; }
[Required]
public string Body { get; set; }
public virtual ICollection<Tag> Tags { get; private set; }
public Post()
{
Category = new Category();
if (Tags == null)
Tags = new Collection<Tag>();
}................................

View 9 Replies

ADO.NET :: Entity Framework - Entity Stored Procedure Mapping - Can't Update

Feb 10, 2011

I am mapping a stored procedure to an entity by right clicking on the entity (in the .edmx) and selecting "Stored Procedure Mapping." This brings you to a Mapping Details - "Name of Entity" Window that allows you to select the insert, update, and delete stored procedures associated with the Entity. It also maps the stored procedure parameter to the Entity "Property" (Column).

I'm gettin an error "error 2042: Parameter Mapping specified is not valid." The cause of the error is fairly obvious, in the Insert stored procedure that has been selected, a 'CHAR' parameter is being mapped to an Int32 Entity Property. I altered the stored procedure parameter to match the entity, I deleted the stored procedure, readded, and reslected it as the Insert function. I also cleaned, validated, updated model from database. No matter what I do, the parameter list in the mapping details doesn't reflect the change to the stored procedure. It's stuck on a char --> int32 mapping, even though it has been changed, like it's buried deep in meta data some where.

View 2 Replies

ADO.NET :: Adding A New Entity In Entity Framework 3.5 With Related Data?

Aug 5, 2010

I am trying to add a new entity and have to refernce associated data to add it. I cannot load the Referencetables. Giving "The EntityReference could not be loaded because it is not attached to an ObjectContext." How do i complete this task in Entity Framework 3.5

[Code]....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved