locked
Reading all table Names using Entity Framework 6.0 RRS feed

  • Question

  • Scenrio is,

    I have a local SQL SERVER Database which contains some tables. I want to read data of all the tables properly (Master -Detail  data ) and write that entities to Azure cloud data base. So I want to read all table names first then read data. Please give me your ideas how to do it well

    Saturday, March 26, 2016 4:01 PM

Answers

  • Do you necessarily have to do it in C#? I'm asking because that functionality is already built-in to SQL Sever, if you are using version 2014. Just right-click on the database in SQL Server Management Studio and select Tasks -> Deploy Database to Windows Azure. This migrates the tables and data, as well as other database objects such as views or stored procedures if you have them.

    Edited: If you really need to get the table names, you can send a sql query such as "select * from information_schema.tables" or "select * from sys.tables". Although you can do this in EF 6 with some effort, it's better to just send it through a SqlCommand, since once you get the list of tables you are going to need the SqlCommand anyway in order to send the dynamic queries that select the data from the various tables. Entity Framework would not be of much use here, unless you add entities for all of the tables, in which case you wouldn't need the list of tables in the first place.

    Saturday, March 26, 2016 5:48 PM

All replies

  • Do you necessarily have to do it in C#? I'm asking because that functionality is already built-in to SQL Sever, if you are using version 2014. Just right-click on the database in SQL Server Management Studio and select Tasks -> Deploy Database to Windows Azure. This migrates the tables and data, as well as other database objects such as views or stored procedures if you have them.

    Edited: If you really need to get the table names, you can send a sql query such as "select * from information_schema.tables" or "select * from sys.tables". Although you can do this in EF 6 with some effort, it's better to just send it through a SqlCommand, since once you get the list of tables you are going to need the SqlCommand anyway in order to send the dynamic queries that select the data from the various tables. Entity Framework would not be of much use here, unless you add entities for all of the tables, in which case you wouldn't need the list of tables in the first place.

    Saturday, March 26, 2016 5:48 PM
  • Actually,I want to prepare a utility application that will connect to any underlying database (Oracle,MySql,SQL SERVER). Read data from Db and write that data on Cloud. As Im at starting point. so im trying it on SQL Server first. So im trying to getting ideas from you expert ppl
    Saturday, March 26, 2016 6:44 PM
  • Actually,I want to prepare a utility application that will connect to any underlying database (Oracle,MySql,SQL SERVER). Read data from Db and write that data on Cloud. As Im at starting point. so im trying it on SQL Server first. So im trying to getting ideas from you expert ppl

    Of course, this has nothing to do with any ORM. It has more to do with using MS SQL Server Command, Oracle Command and MySQL Command objects using T-SQL for MS SQL Server and MySQL and P-SQL for Oracle with just straight up ADO.NET.  

    An ORM is not a Swiss army knife,  and you have the make the Swiss army knife using traditional ADO.NET means without an ORM being involved. 

    Saturday, March 26, 2016 8:23 PM