Last post Jul 21, 2017 11:07 AM by DA924
Jul 21, 2017 12:16 AM|newonehere69|LINK
I am trying to convert the code below to EntityFramework.
using (var cnn = new SqlConnection(p.dbConnection))
SqlDataAdapter cmd1 = new SqlDataAdapter("select * from Pages where Active = 1 order by Name", cnn);
DataSet ds = new DataSet();
SqlDataAdapter cmd2 = new SqlDataAdapter("select * from SubPages where Active = 1 order by Header", cnn);
parentRepeater.DataSource = ds.Tables["pages"];
Is it possible?
Any ideas or examples will be helpful.
Jul 21, 2017 01:00 AM|Kelmen|LINK
u should go through the tutorial
since u already have the database, so u should adopt database-1st approach for ef
include the ef into yr project
create a datamodel through the wizard, select ur database
then start using the generated codes/entities, dbcontext etc
Jul 21, 2017 07:34 AM|Cathy Zou|LINK
In Entity Framework, an entity can be related to other entities through an association (relationship). Each relationship contains two ends that describe the entity type and the multiplicity of the type (one, zero-or-one, or many) for the two entities in
that relationship. The relationship may be governed by a referential constraint, which describes which end in the relationship is a principal role and which is a dependent role.
For more information about how the Entity Framework manages relationships between the entities. It also gives some guidance on how to map and manipulate relationships.
Creating an association with the EF Designer:
If you use code first, you could refer to the following link to learn how to relate table with another table:
Jul 21, 2017 11:07 AM|DA924|LINK
You should look into using EF DB first.
here is a tutorial using EF DB first, but it's using EF 3.5. But it shouldn't not be hard to make the tutorial use EF6