I am porting my SQL Server database to Azure SQL. The database has been replicated correctly and is now accessible from my existing web application.
However, the first time it was executed with the Azure SQL connection string, it showed "Invalid Object" for a table name used on the log in page.
I was able to correct it by adding the schema name [dbusername].[tablename] in place of [tablename] in the code.
Now since it is an extensive application, with over 300 ASPX pages and 30 tables, I'm wondering do I have to use the Find-Replace tool in Visual Studio or am I missing a setting that can help me to assign the default schema name while executing all queries ?
Set the default schema for your user.
USE MyDataBase;
GO
ALTER USER MyUser WITH DEFAULT_SCHEMA=MySchema;
GO
I believe this article will help you.
http://blog.sqlauthority.com/2008/12/26/sql-server-fix-error-msg-15151-level-16-state-1-line-2-cannot-alter-the-login-sa-because-it-does-not-exist-or-you-do-not-have-permission/
Related
I would like to change my schema dynamically depending the HTTP Request based on the UserID. I know that the OnModelCreating is just started one time and i try the DB Interceptor with Npgsql but no sucsess !
I have a specific schema by user and i would like to read and write some data inside.
Techno: Asp.Net 4.5
Thank you
In PostgreSQL, the schema that is search/defaulted can be set on the ConnectionString. The parameter is called "Search Path". More information can be found here.
So if you have control over the connectionstring before connecting you can add the parameter ;Search Path=ABC_USERID,public. This says that look to ABC_USERID schema and if it doesn't find it then search in public schema
As long as you don't qualify the table name with a schema it will for the objects in your search path.
-HTH
Right click on the EF Model Designer surface and choose Update Model from Database.
In the dialog box that pops up, you should be able to browse the database, and select objects to add. But in this case, nothing can be selected:
Removing the Connection String from the App.Config and allowing the Designer to re-add it did not resolve the issue.
The credentials used in the Connection String when copied and pasted in SSMS.
The database can be browsed from the VS Server Explorer window.
Creating a new blank EF project and repeating from there works fine.
What could be causing this?
One of 2 problems exist, the Model already has the Tables/SP/View you are looking for or the Login does not have the Authority the access those Tables/SP/View.
One of the factor unable to select any checkbox in Update Wizard is you don't have any updates in your database, therefore entity framework doesn't allow you to select.
If your scenario is not the factor above, you may try the method I listed below:
I had this issue too and I noticed that I didn't grant the db_owner under Database role membership for my database (eg 22Aug_M) in Microsoft SQL Server Management Studio.
After I checked it and it works as normal.
I have no experience with web hosting. This would be my first application to host.I have an MVC 5 application with Entity Framework. It is locally using two DBs, the one that I created (BailBond) and the default one named "aspnet-BailBondMS-20160913064154" because my project name is BailBondMS. When I publish it winhost, the default DB is not connected to the application. I manually tried to create a DB in my site database in winhost with the same name but it wont let me do it because the name is too long. I then shortened the name. The problem now is that I cannot update the default DB name in Visual Studio to match the one in my control panel in winhost.
What should I do? What am I doing wrong? Thank you for your help.
I have sharding in SQL Azure.
Basically my structure is like below:
1. Master Database
2. Shard0
3. Shard1
I store all non sharded client into master database but on special request from client, i create seperate shard from them.
While reporting sometimes i need to access master database data from say Shard0.
I have followed all articles available on internet like https://azure.microsoft.com/en-in/documentation/articles/sql-database-elastic-query-vertical-partitioning/
but somehow the [database].[dbo].[tablename] query is not working.
I am using SQL v12 in azure.
You cannot use three part name syntax like above to refer to an external table. You query an external table as if it were a normal local table, i.e., use [schema_name].[external_table_name].
Hope this helps.
Thanks,
Torsten
I am trying to develop a website with C# ASP.net MVC. It's my first time using Visual Studio, C# and ASP.net so I have lots to learn but so far so good.
So far... I started a C# ASP.net MVC project and added a database by going to the Database Explorer and clicking "add connection". I then did some standard CRUD controllers and views.
I am at the stage where I want to implement User authentication. I'm a bit confused here. I am trying to make a custom Membership Provider. So I added it to my web.config file with the correct connection string etc.
When I run the project and go to register I get an error. "Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'."
From searching, I see lots of people have this problem and they always reference their hosting. People say this (http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx) is their solution but when I try pick a database I get an error. Not even sure of my server name.
So at this point I am wondering, did I set up the database right?
EDIT
Adding in a few pics to show exactly what I am doing. This is the aspnet_regsql.exe:
This is the provider with connection string, taken from an example on one of the links given.
This is my customized provider with connection string pointing to the last image.
This is a screen cap when I run the project and go to the default project Account register action:
and finally, this is the error screen when I submit
EDIT
Another update..
I sorted something out but I am not sure if it is correct. I am now getting an error when the page loads: "Invalid object name 'dbo.Tag'"
In order to solve this problem the only thing you need to do is create an application services DB. You can achieve this by running the following command from your Visual Studio Command Prompt
aspnet_regsql
Anyways it seems that your "custom provider" isn't using a custom structure for your DB, which might be the reason why you weren't expecting this error.
If you are using the default implementation, you can access to the user administration using ASP .NET Configuration, located on your project menu in visual studio.
The default implementation uses the following conn string keyword
LocalSqlServer
The are many ways of implementing the membership provider. My guess is that probably this conn string is not pointing to your aspnet services db, you could do something like this to specify a custom location for this db
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\aspnetdb.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
I made a blog post regarding this topic: How to use MembershipRole Provider and when to use custom implementations
It's hard to figure out anything from your post.
but when I try pick a database I get
an error.
You can check your server name in Surface area configuration or Sql Server Configuration Manager. If you installed Visual Studio it's probably YOUR_MACHINE_NAME\SQLEXPRESS. You can connect to it using Windows Authentication. You could also write localhost,1433 instead, but that would require enabling TCP/IP first(it's disabled by default) and setting the port number first(which in most cases is already set).