I have ben following through a tutorial that shows how to get started creating a Web Forms Application in ASP.NET...and have got to the part where you create Data Classes. These assume you are starting from scratch and generating the database from code - however - I already have a database created and populated from elsewhere.
Entering line by line to create the Class for each table seems very laborious. (I'm using VB.Net and VS 2013 by the way)
Q1. Can anyone help by suggesting a more automated way of doing this? Surely there is a tool to grab the schema?
Q2. Although the tutorial mentions Entity Framework and Code Behind briefly - having done some reading and research - I am very confused by all of the different terms for data access. Am I using ADO.NET ?? Is the methodology called Code Behind as opposed to something else? Are there better ways to connect to a database and Read/Update/Delete records.
Q3. If I want to use a Data Grid to show the data do I use the generated classes to do this - or just 'bind' the grid directly to the database?
I have been a developer for 40 years but the newer .Net models are causing me some confusion so any advice gratefully received. (and any simple books or tutorials that can be suggested would be helpful).
Thanks
Q1: What you want is to generate "EF Designer from database" by using a Entity Data Model.
In your project add a new item and look under "Data".
What this technique does is auto generating entity classes from your predefined database.
Q2: I suggest you read Getting started with Entity Framework. "Database First" is just a description of how you want to use the Entity framework - by saying you already have a database structure.
Q3: In this case if you use Entity Framework and the "database first" mechanism to generate entities you can databind the gridview from the result of a entity LINQ query, please see this example: Tutorial: Databinding
Related
All tutorials I can find is with database or entity framework. I just want a simple class as model with field creation and update from the view and using .aspx template.
Can somebody give me as simplest example as possible or point me an article on the web I've bee googling all day long without finding any.
Simply use an EF Code First tutorial and remove the calls to DbContext - without DbContext, the entities are simply POCOs. Replace those calls with however you plan to persist/read your data.
I'm using Entity Framework 5 with large database with 600+ tables (haven't counted stored procedure and views yet). After few start and running using Visual Studio 2012 I get Out of Memory error when trying to Update my Model.EDMX file (using right click Update from Database) or simply while trying to compile.
Quick google search says many people faced similar problem and someone in one forum suggested to use multiple EDMX files to avoid this.
(link http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/b4ce1494-a0b4-42c6-af56-4ecbfeb83e29)
My question is
1) Is there any way I can avoid this error and use large number of tables without trouble with EF?
2) Is Entity Framework model is right ORM for me for large enterprise database? If not, can someone suggest me good one?
Thanks in advance
To answer your first question.
I have found that updating the Entity Framework does not seem to work reliably in all cases.
Have you tried deleting all the objects in the model and inserting them again? It may be an acceptable workaround.
I'd recommend spending some time looking into nHibernate. It's not as user friendly in terms as UI than Entity Framework but that should be an advantage for you if you are dealing with a large number of tables.
http://nhforge.org/Default.aspx
Also, you're aware that you don't have to map all of the tables in your Entity model? You can just bring in the ones you need. I'm assuming that you don't need all 600 tables for what you're doing.
Can anyone tell how to update table rows dynamically in entity framework? I am new in entity framework. Thanks in advance.
This is a pretty general question, but what you need to do is basically this:
Access your data context.
Get a given object (/record) from your context (/database).
Change the object.
Call SaveChanges() on the data context.
If you are learning EF a site that helped me a lot when I was learning it is http://msdn.microsoft.com/en-us/library/gg696194(VS.103).aspx. It contains lots of information in problem/solution format. You can also look at this book:
http://www.amazon.com/Programming-Entity-Framework-Building-Centric/dp/0596807260/ref=sr_1_1?ie=UTF8&qid=1355991856&sr=8-1&keywords=entity+framework
or this book:
http://www.amazon.com/Programming-Entity-Framework-Code-First/dp/1449312942/ref=sr_1_4?ie=UTF8&qid=1355991858&sr=8-4&keywords=entity+framework
which are both quite useful depending on whether you wish to use the designer or Code First.
I need some advice on a little project im doing. I have a database which holds sales details, I have created a view which gets all the data that I need. I now need to get the data from the view manipulate the data and display it on the website.
please can you advice me on the best way i can get the data from the database to my asp.net application.
iv set up a datasource on the webpage, but im a bit stuck on how i can manipulate the data from this datasource.
UPDATE
sorry i forgot to mention that im using Interbase so im having to use a ODBC connector to interface between asp.net and the database. i was under the impression that LINQ2SQL is only for SQL server. normally i would just use data reader and put that into a dataset, but due to the interbase issue im having to create a SQL data source. – c11ada 1 min ago edit
You have different options:
Read data directly with DataReader or Dataset
Use Linq2SQL Use
Entity Framework (EF)
I would recommend using LINQ or EF because they are simpler and Object Oriented. Between them probably LINQ is simpler to set up and EF is more powerful.
It is easy to find info and examples of all those options.
That depends on the quantity of manipulation and your skills. Using datareader or dataset is normally have good knowledge then other techniques even though they are standard and good to use.
As #gustavogb suggested you can use anyone, but that really depends on your skills and interest to upgrade the knowledge.
I know Linq to SQL work such as setting META attributes around your model. What i am looking to do is building my model then setting this model to work with EF 4.
Are the same approach working with EF 4 ?
Is this called the Code-First approach or its totally something else ?
Ive done some research but i can't seem to figure out how exactly to map a domain to work with EF 4. This include keys/relations integrity.
I would love to see a simple code example with some explanations.
Thanks.
Model-first development allows you to build the model in the designer, then generate the database based on that model. Code-first allows you to generate the database based on your code, or use the code to work with an existing database too.
Both those options are viable; for code-first, V5 has a lot of improvements you will want to look out for.
HTH.