How can I use Sparx Enterprise Architect with Code First? - ef-code-first

We are currently using Entity Framework 6 (EF) Database First approach to generate and maintain our database model classes.
I was hoping to use Sparx Enterprise Architect (EA) to maintain a SQL Server 2012 EE database design, and then EF Database First to "Update Model from Database" to maintain the EF model classes.
Now that Microsoft has officially announced they will no longer maintain any EF design approach besides Code First, how can I work with Sparx EA to keep our Code First models up to date if I do some database redesign with EA? I know Sparx will go 2 way with the database itself, but that does not help with Code First after the first creation of the Code First model created from the database, as I can't keep importing the entire database into Code First or we would lose our Code First customizations.

I've tried EA with EF and decided to go with pure EF Code First. It is a lot easier since EA just doesn't work with EF at all well. Thanks for the suggestions. Chris, if you will post as an answer will be glad to mark it as such. You were right...

Related

Creating Classes from Exising Database

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

Out Of Memory when using Entity Framework with large database (600+ entities)

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.

ASP.net c# help with data manipulation

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.

How Entity Framework 4 domain mapping work exactly?

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.

ASP.NET MVC and Linq, when to use?

I just started working on an asp.net / C#.net application that is going to call a number of different procedures. The -only- thing these procedures do is create database table views, and the only thing I want to do is to store the information in variables. Then pick out which columns I want to convert to JSON, and then make a JSON string. I've actually written code for that in C#.net already, which is smaller, but since I switched to asp.net mvc I'm a little unsure if I should keep it or go with the whole Linq thing.
I checked out the Linq --> SQL drag & drop functionality, and that instantly created about 200 lines of code with set & get methods and everything.
So my question is, is it still worth using Linq even for just extracting data? Eventually this data will be fed to a javascript timeline, which is where I was told MVC would be highly useful with regards to Ajax functionality.
Since you are only using LINQ-to-SQL for data retrieval, I can't think of a single reason NOT to fully utilize it. I've been working on an MVC 1.0 project since last April. During that time, I've had to quickly become familiar with a number of technologies, LINQ-to-SQL being one of them. Get comfortable with it, and also look at the repository pattern...you will be very content and things will go relatively smoothly.
Now, when you get to INSERTs and UPDATEs, things are going to get a little more sticky. LINQ-to-SQL is still up to the job, but you'll need to understand how things work internally a little better. I highly recommend "Pro LINQ (Language Integrated Query) in C# 2008" by Joseph C. Rattz, Jr. The sections covering LINQ-to-SQL easily take up over a third of the book with detailed examples.
As far as the JSON objects go, LINQ-to-SQL's biggest contribution is that it allowed me not to have to worry about creating specialized views or stored procedures just to handle those one-off-types of data retrievals. My current project has a database of 65 tables...NO stored procedures. I can do filters, unions, multi-level joins...and it's all maintained in the application. Sweet...
Yes, it's totally worth it!
LINQ2SQL provides you a great subsurface to retrieve and save data to.
However, you'll need to implement your own Repository Pattern as you dig deeper into ASP.NET MVC.
And during the implementation of the Repository and the required (and even custom / webapp-state based) Queries, you'll be very glad to have all the power available at your fingertips that LINQ provides.
LINQ only adds to the available toolkit you can lean on when creating code. Even if you are using LINQ in a trivial way now, implement it, get familiar with it, and take advantage of the power it gives you both on this project and future projects.
Linq2Sql is quiet good for creating select queries. As it is appearing that you need to create JSON objects from database views it will be quiet useful

Resources