SQL71501:has an unresolved reference to Schema [win] - sql-server-data-tools

I am getting a unresolved reference in a SQLProject, the error occurs on the create line. All objects are causing it because they are all being created in a specific schema.
For example I have Table that is being created in a specific schema"win"
Create Table [win].[DataSource]. The error occurs because of the attempt to create it in the "win" schema If I remove the schema from the create statement the error goes away. The database project is a composite project including all of the artifacts (stored procs, tables, views...) from the win schema. Here is an example of the error I am seeing.
Severity Code Description Project File Line Suppression State
Error SQL71501: Procedure: [win].[SelectCandidateExamSearch] has an unresolved reference to Schema [win].

Create script with Build Action: build with the following SQL statement:
CREATE SCHEMA [win]
where [win] is the schema name.
For any database project in VS to build sucessfully, ALL its references must exist in the scope of the project and be valid.

Related

Issue with Snowflake schema migration with flyway command line

I'm trying to migrate snowflake schema with flyway. Using below command:
flyway migrate with url and other required parameters
I got below error:
Flyway Community Edition 6.3.0 by Redgate
Database: jdbc❄️//.snowflakecomputing.com:443/ (Snowflake 4.8)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.snowflake.client.jdbc.internal.io.netty.util.internal.ReflectionUtil (file:/C:/flyway-6.3.0/drivers/snowflake-jdbc-3.12.2.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of net.snowflake.client.jdbc.internal.io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
ERROR:
Unable to check whether table "PUBLIC"."flyway_schema_history" exists
SQL State : 02000
Error Code : 2043
Message : SQL compilation error:
Object does not exist, or operation cannot be performed.
'warehouse' is not recognized as an internal or external command,
operable program or batch file.
'role' is not recognized as an internal or external command,
operable program or batch file.
I don't know why this error because I'm passing all the parameters correctly
From the error, it looks like Flyway can connect but can't find "PUBLIC"."flyway_schema_history".
When an object is double-quoted like that Snowflake recognizes that as case-sensitive.
You might want to:
Try connecting to Snowflake directly via your regular web login and then seeing if select top 1 * from <database>."PUBLIC"."flyway_schema_history" works correctly. Check to see that you are passing in a database parameter since I can't see that in your query.
See if you can connect in both the Snowflake website without the double quotes and in Flyway so that select top 1 * from <database>.public.flyway_schema_history also works so you remove case-sensitivity as a possibility.

In Corda, schema cannot be cast to net.corda.core.schemas.MappedSchema exception

I am trying to create migration schemas for a CorDapp as per the instructions here. I am running the following command:
java -jar corda-tools-database-manager-3.1.jar
--base-directory /opt/User
--create-migration-sql-for-cordapp fnolUseCase.state.FNOLSchema
However, I am getting the following error:
-- 2018-08-22T13:29:23,145Z migration.tool.invoke - Creating database migration
files for schema: fnolUseCase.state.FNOLSchema into /opt/User/migration
Failed to create datasource.
Please check that the correct JDBC driver is installed in one of the following
folders:
- /opt/User/drivers
Caused By java.lang.ClassCastException: fnolUseCase.state.FNOLSchema cannot be cast
to net.corda.core.schemas.MappedSchema
What should I be doing differently?
It seems to be having trouble locating your fnolUseCase.state.FNOLSchema class. Try dropping the schema name from the end of your command. This will cause a migration schema to be created for every schema in your application:
java -jar corda-tools-database-manager-3.1.jar
--base-directory /opt/User
--create-migration-sql-for-cordapp fnolUseCase.state.FNOLSchema

Update-database command failed to create database

So I'm studying Entity Framework Core through the course I am following to. So in the video he run the update-database command and it went smoothly, well it is the opposite when I tried the command. I already done the add-migration then just need to execute the update-database commaand.
Here's the error.log: Error Log Link
I have some idea that it is because of my userprofile that I get this error since it contains spaces.
Anyways here the error message I get from the package manager console:
Error Number:5123,State:1,Class:16
CREATE FILE encountered operating
system error 5(Access is denied.) while attempting to open or create
the physical file 'C:\Users\Infinite RegressionAngelShop.mdf'.
CREATE DATABASE failed. Some file names listed could not be created. Check
related errors.
Try to update MSSql to the latest version. It worked for me.

Error Running Mixed SQL and Java Migrations - Error executing statement at line 1: package db.migration

I'm trying to run a mixture of SQL and Java migrations via Maven based on the example from Axel Fontaine here: http://www.methodsandtools.com/tools/flyway.php
Basically I am trying to execute several SQL migrations, followed by a java migration (to load BLOBS into a table), then followed by another SQL migration.
The first set of SQL migrations run fine. If I specify a file extension of .java for the Java migration, it gets ignored. If I specify a file extension of .sql for the Java migration, it gets run in the correct sequence, but I get the following error:
[ERROR] com.googlecode.flyway.core.api.FlywayException: Error
executing statement at line 1: package db.migration [ERROR] Caused by
org.postgresql.util.PSQLException: ERROR: syntax error at or near
"package" Position: 1 [ERROR]
com.googlecode.flyway.core.api.FlywayException: Migration of schema
"test" to version 1.0.0106 failed! Changes successfully rolled back.
Here is the head of my Java migration file:
package db.migration;
import com.googlecode.flyway.core.api.migration.jdbc.JdbcMigration;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.io.File;
Any ideas as to what I'm doing wrong?
Okay, I finally figured out what was going on. While Flyway allows version numbers that contain "." in the name (ex. V1.0.0000_filename), apparently it is not supported for Java migration class names. I changed the class name to use "" instead of "." (V1_0_1000_filename) and that allowed me to get past the original error.

ASP.NET Schema Tables Causing Issues in VSTS

After installing the VSTS Database GDR and importing a SQL Server 2005 database that includes the ASP.NET provider schema tables, I get the following warnings:
TSD04151: Procedure: [dbo].[aspnet_Users_DeleteUser] has an unresolved reference to object [dbo].[sysobjects].[name].
TSD04151: Procedure: [dbo].[aspnet_Users_DeleteUser] has an unresolved reference to object [dbo].[sysobjects].
TSD04151: Procedure: [dbo].[aspnet_AnyDataInTables] has an unresolved reference to object [dbo].[sysobjects].[type].
TSD04151: Procedure: [dbo].[aspnet_Users_DeleteUser] has an unresolved reference to object [dbo].[sysobjects].[type].
TSD04151: Procedure: [dbo].[aspnet_AnyDataInTables] has an unresolved reference to object [dbo].[sysobjects].
TSD04151: Procedure: [dbo].[aspnet_AnyDataInTables] has an unresolved reference to object [dbo].[sysobjects].[name].
Does anyone know how to get rid of these warnings?
I'm not sure, but a quick look seems to reveal the following.
The offending line in the script seems to be:
Line 42 in procedure [dbo].[aspnet_Users_DeleteUser] (how do you do underscores here?) (like this: \_ )
(EXISTS (SELECT name FROM sysobjects WHERE (name = N'vw_aspnet_MembershipUsers') AND (type = 'V'))))
the system view sysobjects belongs to the built in system schema 'sys' which is not included in the database project. As a result the database project parser thinks (wrongly) that the reference is unresolved.
I don't think there is anything you can do but select to ignore the warning from the project settings. (Be aware that that will hide real errors from you as well.) I would probably just ignore the warnings.
Update:
Try to add a reference to:
C:\Program Files\Microsoft Visual Studio 9.0\VSTSDB\Extensions\SqlServer\2008\DBSchemas\master.dbschema
Kim's answer above works perfectly for the situation I asked for. But, I also found out that you can filter the build warnings per file. Look at http://blogs.msdn.com/gertd/archive/2009/01/11/file-level-build-warning-suppression-in-the-gdr.aspx

Resources