how to target sql server 2008 with EF Core - ef-core-2.1

Building a razor pages application usign ef core 2.1.1. Development DB server localDB, target SQL server SQL 2008 r2.
I get the following error on the target server:
System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near 'OFFSET'.
Invalid usage of the option NEXT in the FETCH statement.
I suppose the generated SQL code is targeted to SQL server 2012 and up.
How do I force ef core to generate code for SQL server 2008?
Thanks!

EF Core, or more specifically the underlying driver used when interacting with SQL Server Microsoft.EntityFrameworkCore.SqlServer only supports SQL Server 2012 and onwards. Reference
One alternative to make your Skip and Take queries work is to use the below when configuring your DbContext
services.AddDbContext<MyDbContext>(options =>
options.UseSqlServer(connection, opt => opt.UseRowNumberForPaging()));

Related

Is Entity Framework EDMX file provider specific?

I wan't to use Sql Server 2008 as production environment with provider System.Data.SqlClient and Sql Server compact 4.0 with provider System.Data.SqlServerCe.4.0 for integration testing with SpecFlow.
Is it possible to use the same edmx file in Entity Framework for the different environments?
In case of Yes as an answer, how can I split the EDMX and keep different mappings?
I already have the production environment working with Sql Server 2008 and have generated a Sql Server compact 4.0 file (.sdf) from the Entity Model but when i try to connect to the compact database it gives me various errors.
I found this line in my EDMX file:
Provider="System.Data.SqlClient"
I think it will be possible to use SQL CE, if you change the values as folows:
Provider="System.Data.SqlServerCe.4.0" ProviderManifestToken="4.0"

I am trying to open DTS packages in SQL Server 2008 R2, but getting error

I am trying to open DTS packages in SQL Server 2008 R2. But I'm getting this following error
sql server 2000 DTS Designer components are required to editDTS
Packages.install the special web download, " sql serevr 200 DTS
Designer Components" to use this feature
.(microsoft.sqlserver.dtsobjectexplorerUI)
Anybody help how to make it work?
As I already installed the SQLServer2005_BC.msi & SQLServer2005_DTS.msi
Your question subject says SQL Server 2008, the error message says SQL Server 2000, and you installed SQL Server 2005's MSI. You have three different versions of SQL Server in the three items.
You're trying to install something that either isn't the right version for the SQL Server version you're using (2008), or is no longer available or required for SQL Server 2008. You need to find the proper means of editing DTS files for SQL Server 2008, or research what replaced them in SQL Server 2008.

Is it possible to use SQL profiler 2005 to profile a 2008 database

I'm trying to trace a SQL Server 2008 database, but I only have SQL Profiler 2005 available to me. (Don't ask why, it doesn't make sense to me either). When I try to start a new trace, I get "Unable to locate trace definition file for Microsoft SQL Server version 10.0.0. Click OK to retrieve it from the server. Retrieval may take a few moments".
I click Ok, then ... nothing.
Is there a way I can get this to work?
You have to copy files from a SQL Server 2008 installation into the SQL Server 2005 installation. Copy "Microsoft SQL Server TraceDefinition 10.0.0.xml" (and "Microsoft SQL Server TraceDefinition 10.50.0.xml") from "C:\Programme\Microsoft SQL Server\100\Tools\Profiler\TraceDefinitions" into "C:\Programme\Microsoft SQL Server\90\Tools\Profiler\TraceDefinitions".
To be able to save templates, you have to create a new folder in "C:\Programme\Microsoft SQL Server\90\Tools\Profiler\Templates". For SQL Server 2008 add a directory named "100", for SQL Server 2008R2 add a directory named "1050". If you don't have access to an SQL Server 2008 Profiler installation, you can copy the existing templates for SQL Server 2005 from "C:\Programme\Microsoft SQL Server\90\Tools\Profiler\Templates\90" - they work with SQL Server 2008 too.
I think this should be possible, provided you can get the SQL2008 trace definitions, the ones that install with SQL2005 are located here:
C:\Program Files\Microsoft SQL Server\90\Tools\Profiler\TraceDefinitions
If you can get the SQL2008 versions (they are XML files) you should be good to go, hope this helps!

How to change target database server in SQL Server?

I was trying to use TRY..CATCH feature in SQL Server 2005's Stored Procedure but it didn't worked. I checked my version using ##VERSION, it displayed "MS SQL Server 2000 - 8.00.194 (Intel X86) " but when I clicked on Help->About, it displayed "9.00.1399.00" which clearly specifies that I have SQL Server 2005 installed.
I know that TRY..CATCH can only be used on SQL server 2005 or above..
My system might be using Sql Server 2000 as source database or something like that, I might be wrong in describing. How to change it then..
After re-reading your question, you clearly have SQL Server 2005 client tools (SSMS) installed, and have your database on a SQL Server 2000 server, so you cannot use TRY..CATCH. Period.
Assuming you really do have a SQL Server 2005 server, have you ensured the specific database has its compatibility level set to 90 (SQL Server 2005)?
Right click database->Properties->Compatibility level
This can happen if you upgrade the server and forget to upgrade the database compatibility level.
help..about gives you the version of the client tools (SSMS)
SELECT ##VERSION gives you server version
If the server version is 8.x then you have SQL Server 2000 which does not support TRY/CATCH. No amount of fiddling with Compatibility level will fix this.
You have 3 practical options
Don't use TRY/CATCH
Upgrade your server version
Install a names SQL Server 2005 instance on the same box

How do I use MySQL as data source in Microsoft SQL Server Analysis Services?

I have installed the latest .net connector, I can add MySQL databases as Data Sources, I can even browse through the data from Business Intelligence Studio.
The problem is that I cannot create a datasource view, or if I do create one without tables, trying to add them after the fact gives me the same error.
Specifically it looks like the data source view wizard tries to submit queries against the MySQL database using square brackets/braces, and the query bombs.
I get an error message like:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[my_db].[cheatType]' at line 2
How can this be done?
Get the MySQL ( 6.3.5 ) .net connector ( from MY SQL )
Edit the connection string ( in the designer paste in the connection string ) so that it has the new "SQL SERVER MODE=True" option.
Apparently it affects performance - but what can you do
My sample connection string...(passwords & userids omitted )
server=svr215;User Id=;password=;Persist Security Info=True;database=dw;sql server mode=true
For any of you facing this issue more recently, there are two approaches that you may want to consider as well
Use the DevArt dotConnect connector at http://www.devart.com/dotconnect/mysql/. Using the .NET data source, you can connect your SSAS cube directly to MySQL.
Some have worked with doing OpenQuery connections to MySQL by connecting to SQL Server for the DSV and then using a linked server connection to MySQL. Some of those details are noted within http://dennyglee.com/2012/09/26/sql-server-analysis-services-to-hive/.
Try using Caps when adding it to the connection string:"....;Sql Server Mode=True"
Tried using named queries instead of tables?
Create a new named query in the DSV, as SELECT * FROM MySQLTable, then build in the DSV on top of that.
I would recommend using SQL Server. You will save yourself a lot of time and headache trying to do it this way. If your tables don't need transforming, just use SSIS to move the data from MySQL to SQL Server.
This is what we did at my previous employer - OLTP was MySQL and we built the warehouse in SQL Server, then used SSAS off of that warehouse for the cube.
I have tried with Visual Studio 2015 and SQL Server Data Tools 2015 on Windows 7 Machine, experiencing problems with the following versions:
net connector 7.0.4
net connector 7.0.3
net connector 7.0.2
net connector 6.9.8
net connector 6.9.7
net connector 6.9.6
net connector 6.9.5
net connector 6.9.4
net connector 6.9.3
net connector 6.9.2
net connector 6.9.1
net connector 6.9.0
net connector 6.3.5
from here: https://downloads.mysql.com/archives/c-net/
As a result:
The SSIS is working but SQL builder always failing.
The SSAS is not woriking as it cannot retrieve the database schema.
Finally, after hours i got it working with the following installation of new product of MYSQL Community from here: http://dev.mysql.com/downloads/file/?id=466291
Now, the only problem i expirienced was that the connector was unable to translate some queries due schema mapping, so setting sqlservermode=true to the connection string will fix that problem too!