Compare between two databases have the same tables - asp.net-mvc

I have 2 databases, each of which has 2 tables, Employee and Department.
One of them is old and the other one is the new one.
I want to compare the data between them. I have make DTOs classes and mapping between entities and the DTOs classes using Automapper.
Can anyone help me step by step to compare these databases using EF?
Compare the data from old database to the new database.
Depending on the comparison show result in one of four groups:
Data already exist with no change
New data ready to be moved
Data to be updated
Data to be deleted
Then I can deploy the changes to the new database

Related

Entity framework database first best practice for managing a DB

i would like to know if there is someone that can help me find the best way to manage a db with 50 tables that i assume has to be structured in my mvc application as multiple EMDX files for performance but that will have multiple connection strings that i hate.
So let's make a short example:
i have a join of 5 tables to create a customer list grid
and another 3 tables join for an employee grid.
I created two edmx context files to manage each grid and i have 2 connection strings.
Now, if i haev to create 30 grid will i have to create 30 edmx files and corresponding 30 connection strings?
The question is: is this the best practice for this? duplicating 30 times the connection string that connects to the same db?
Thanks
I am not sure why you need separate connection string. If you are connecting to same database then one connection string is enough.
Also if i understand correctly you are creating separate edmx file for each grid. This is not correct way of using Entity Framework. You should be using only one EDMX file for a database, 50 tables is not a big number. If you have complex query then i'll suggest to use store procedure and call it via Entity Framework using function import

How to get the data from different tables from different data models using telerik open access

I am using Telerik open Access, I have three different data models like:
UserEntitiesModel->account_details
ProfileEntitiesModel->biographic_details
ContactsEntitiesModel->contact_groups
I have three different tables in different data models. I want to load the data from all the tables; I used joins and wrote the lambda expression, but it is throwing an exception
InvalidOperationException unhandled by user code
Can you tell me how to retrieve the the data from different tables in different data models?
You see, different models (rlinq) files generate different Context objects (the ones deriving from OpenAccessContext), they in turn have different internals used and are completely separate. This means you cannot combine them in a LINQ query.
LINQ queries are per-context and are (usually) executed on the sql server. OpenAccess cannot know how two models correlate and whether they are from the same database instance.
That being said, if the data models are just different parts of the same database (and use the same (or similar) connection string) you should be able to aggregate the models into a single context object. The context objects are initialized with a MetadataSource, and you can merge the models you have into a single one, using the AggregateMetadataSource. You will need to implement your own Context object, and it is more work, but it should work.
If you don't want to go into such trouble, you can always enumerate the results from your tables using .ToList() before using them in the LINQ query. This however means that you will be retrieving more data on the client that you wouldn't need otherwise.

In Entity framework 4.0 how can we fetch multiple record set from database in one call & pass all data to View

In Entity framework 4.0 how can we fetch multiple record set from database in one call like we do in ado.net dataset?
Soppose we have 3 table T1,T2 and T3. We need to fetch data from all tree table and pass to view(ASP.NET MVC3). No JOIN is to be used as all are independent table. Instead of making 3 call to database we want to wrap up all select statement in one SP and make only one call to database and pass all data to view.
In case of dataset if stored procedure return data from multiple select statement dataset populate each recordset in different table.
How can we achieve it in EF? Please help me.
Thanks,
Paul
There is no out of the box feature to batch queries in EF. But there are some efforts made by others to extend EF to support this.
Entity Framework Batch Update and Future Queries
MultiQuery
(more queries in one batch) in Entity Framework using LINQ

How do you query multiple databases for one view in ASP.NET MVC?

I have three databases, x, y, z. Let's assume MS can speak to all of them via odbc or something else.
When I was in webforms I would create a tableadapter and conduct a query. I could do this for each connection I had, so I had three queries.
I would drop each connection and dataset on my page. Each control I used would call the appropriate dataset and populate it's gridview or whatever. All was well. I had three databases, three hits, all on the same page, for one integrated page for the customer.
How can I do this same thing in ASP.NET MVC? Please.
Thank you.
You get your data from your databases and return all the results in your ViewModel
the simplest way would be to get it all in your controller, assign it to your model the send it to your view
Using ASP.Net MVC entity framework, create entity classes for each of the 3 databases (Here it's assumed that you are querying entirely different tables from 3 different databases). What you get here are 3 entity classes, each having it's own properties that directly correspond to the table column names you are retrieving. Now, you don't need to worry about 3 databases. Entity framework abstracts it into a set of properties that map into different tables in x,y and z databases you are retrieving from.

Forcing a bridge/join table to become a many to many relationship in EF4

I have a simple database with 2 main tables with a many to many relationship through a 3rd bridge/join table.
This 3rd table has an extra field besides the two keys required, so that Entity Framework transforms it into a full entity rather than a many to many relationship between the other 2 tables.
I cannot change this third table in the database itself. Is there a way to ignore the extra field so that EF can do what I want, or a way to manually transform the bridge table into a many to many relation?
Yes, update the store schema (SSDL) to remove the additional fields and regenerate the MSL/CSDL. The easiest way to do this is to create your mapping with a DB which doesn't have these fields. It will work fine against the "real" DB at runtime.

Resources