Cross join databases - sql-server

Project: RecipeRolodex
Mission: Create database (Entity Framework, data-first) and ASP.NET MVC5 Application to create and manage catalog of recipes.
Tech: SQL Server 2012, Visual Studio Enterprise 2015
Database diagram - Recipes
https://sqldbm.com/Project/SQLServer/Share/lE7q9CWGgGiR0I-o8mWAAA
My database has been created, the application can read/write data out of it. I'm developing the process to actually create the recipes (the scaffolding isn't sufficient).
I know that the recipes table should contain a foreign key relationship to a UserID in the AspNetUsers table.
I allowed the application to build a new database for ASP.NET Identity.
How would I go about accessing Recipes based off of UserID?

I have had to deal with an issue like this before. I would suggest moving the data to ONE database - really helps with keeping the database relational, which is what makes SQL-server a good database. Also will help with over all speed when dealing with JOINING tables.

Related

.Net Core Identity - migrate from Postgresql to SQL Server

I have a .NET Core 3.0 MVC website with Identity. The database is a Postgresql database (mainly because of better performance with geographic data). But since the only other person that can work with postgresql has quit, i have to migrate to SQL Server (because of internal policy).
But there isn't much information on the big web on this specific migration.
I got a few ideas but since setting up a test takes quite some time, I wanted to check here first.
Is it just a matter of copying all tables between the databases (Copy/export data - change connectionstring - people won't even notice the change)?
write a small script using entity framework, copying all users to the new database with a default password - users have to change password on first login
people have to re-register
a combination of the above
EDIT: the problem is not the tables and data types but my concern is the passwords and the hashes. Can I just copy all the values to the SQL database and can people just log in?
There is a password hash in the table and I was thinking it maybe used other variables like the database engine to create the hash.
If the application is build on the same stack, lets say in your case Dot net core with Aspnet Identity, then the hashes can be migrated with no issue at all. Everything is handled by dotnet and it is not bound to the underlying datastore.
Create the schema and populate it and you will be good to go. No need to rehash or make your users change their passwords. Just move the data
You will need to figure out which data types you are using in Postgresql and what their equivalents are on MSSQL. Most data types are same/similar while there might be a few where there is no direct equivalent.
There are lots of ways to move data between databases. One possible simple way in this case is to dump your postgres db using pg_dump. This will get you a text file with sql statements to recreate the database. Then you can modify the sql statements as necessary to work on your MSSQL database.

Use Entity Framework automatic migrations only on one SQL Server schema

I've been tasked to create a web API for a vendors database that we host on-site ourselves. What we want to do is create EF data models/db sets for some of the existing vendor tables, but we also want to create a special schema for our custom tables that store the relationships between the vendor data and our other applications.
The thing I've been wondering about is how can we use automatic migrations and database initialization just for our special schema and let the vendor application manage its tables separately on its own. Is this possible?

How do I relate tables in Azure Mobile Service - Javascript Backend

On the azure page I can create my tables but there are only 4 data types and no option to create or relate the tables using foreign keys and SQL.
What I want to do is have a user and contact table with userId in contact table as a foreign key.
I am using apache cordova and angularJs on the front end in visual studio. I have already added the mobile service to my project.
Mobile Services does not directly support relationships in the backend, but you can customize the data using server scripts and the mssql object. Alternatively, you can create database views that have relationships between tables.
For an example of mapping relationships using database views, please see my post in this forum thread: Best Practice For Syncing Related Tables in Offline Mode.
For more information on managing the database directly, see this article: Scale mobile services backed by Azure SQL Database.

How to build database reports using multiple remote databases

Does anyone have experience building database reports - doesn't matter which database - i just want design ideas - for a system that is made up of many separate, but identical databases?
I cannot "combine" all databases into one. They must be separate.
But the structure is identical across all databases...
I need to build a web interface that will allow a user to get a "global" report that will query all databases and build one combined report.
Do you have any comments on how the model would look like? or anything you think i need to beware of?
Thanks.
I don't have first hand experience with cross database reports, my experience comes from a product the company i work for sells which can create reports from multiple databases, from your description i believe you require something of the "combine" tables kind, in this case i recommend you to detect the tables used in the query, and unify them in a single temporary intermediary database, for example Access, SQL Server CE or SQLite and then run the query against this temporary database or table.
If your databases are Microsoft SQL Server, then using SQL Server Reporting Services seems like a good solution. The software for the report generation / display is bundled along with the database software.
It gives you a web interface, where you can configure 'data sources' from any number of remote databases, and combine data from these sources into reports. It is user friendly and you can do all the report design / configuration through the web interface without having to write any code.
some references :
Building report using SQL Server stored procedure
http://blog.hoegaerden.be/2009/11/10/reporting-on-data-from-stored-procedures-part-1/

Entity Framework Oracle and Sql Server - how to build a database independent application

We are trying to build a data access layer for using both Oracle and SQL Server (not at the same time).
We use EF Model-first for creating the model and the create the SQL scripts for building the database. Our first thought was to create 2 EDMX files, one for each type, and use the appropriate one depending on the client's need. We are using the Oracle and SQL Server database generation workflow and DDL generation template to create the scripts for each database.
Our main problem is when the database schema changes we do not want to drop and recreate the DB but only create the migration scripts to update the DB base on our model (clients have many data that will be lost).
We use EF power pack for extracting the migration scripts for SQL Server but there is nothing like it for Oracle.
We want help to find a good data layer (1 EDMX for both Oracle and SQL Server if it's possible and not complicated) and a good way to generate database changes from our model to update existing client DBs in case of a new application release
We found this as a starting point
http://msdn.microsoft.com/en-us/data/ff830362 but there is not mention for Oracle support.
We have tried code-first and EF Migrations but Oracle failed us again on the DB creation and migration.
Any recommendation on how we can accomplish this?
Thank You
There is no way to have single EDMX for both SQL Server and Oracle. EDMX consists of three parts CSDL (entity definition), SSDL (database definition), MSL (mapping between those definitions). SSDL must always target concrete database so you need at least separate SSDL for Oracle and SQL Server and if you are lucky you will not need separate MSL as well (mapping must be exactly same which will probably not happen if you are using any tool to generate the database).
So you always need at least part of EDMX file for second DB and manually maintain it.
If you need DB migration supporting Oracle you must look for tool from Oracle (or third party). For example RedGate offers tools supporting schema migration for both SQL Server and Oracle.
Visual Studion Premium and Ultimate edition also offers tools for comparing database schemas. It by default supports only SQL Server but Toad Extensions should add support for Oracle as well.
Once you have any of these tools you just need to compare schema deployed on customer server with your new schema and the tool should create migration script for you.
The best article I found on this topic is from Paul Reynolds Blog.
Try to go through from part 5 to part 9.
There are so many gotchas about Oracle mentioned there... is very helpful!

Resources