System.Data.Entity.Core.ProviderIncompatibleException - c#

so basically at work I was assigned an old ASP.NET project which is outdated I have couple of months debugging it. Last week the project was working fine then from one moment to another stopped working. When I run the project I get this exception
System.Data.Entity.Core.ProviderIncompatibleException: 'An error
occurred accessing the database. This usually means that the
connection to the database failed. Check that the connection string is
correct and that the appropriate DbContext constructor is being used
to specify it or find it in the application's config file. See
http://go.microsoft.com/fwlink/?LinkId=386386 for information on
DbContext and connections. See the inner exception for details of the
failure.'
Which also have 2 inner exceptions
ProviderIncompatibleException: The provider did not return a
ProviderManifestToken string.
OracleException: ORA-00604: error occurred at recursive SQL level 1
ORA-12705: Cannot access NLS data files or invalid environment
specified
What is causing this error?
When I run the project I have a method called LoadUserInfo(); which displays the user code, user department and username to retrieve this data, the application goes to the oracle database and retrieves this info, but for some reason (that I cant figure out) is not working.

Related

Internal Server Error after publishing and Tables not being created

This issue is only present on the server I've published to. Locally I'm having zero issues.
After publishing from VS2017, the web page is displaying an Internal Server error with no further description on that page. This is not the first time I've published, so this issue is very random.
I'm at my wits end and am totally stumped as to what's causing this. Especially since before I hit publish, it was working fine. Although, it has been quite awhile since I've published from VS.
Things I've tried:
Restarting Server
Repairing IIS and ensuring correct .net core versions are installed.
More server restarting
Ensuring correct DLL's are present(even though this isn't first time publishing)
Check connection strings in appsettings
View stdoutLog output
View event log - this didn't display anything helpful
The stdoutLog stacktrace is as follows:
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile not available. Using 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\4.0.30319.0\AutoGenKeys\S-1-5-82-1102471511-930544150-2645822985-2987586966-3557056008\DataProtection' as key repository and Windows DPAPI to encrypt keys at rest.
Application startup exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: providerInvariantName
at Serenity.Data.DbProviderFactories.GetFactory(String providerInvariantName)
at Serenity.Data.SqlConnections.GetFactory(String providerName)
at Serenity.Data.ConnectionStringInfo.get_ProviderFactory()
at ApexCore.DataMigrations.EnsureDatabase(String databaseKey) in DataMigrations.cs:line 40
at ApexCore.DataMigrations.Initialize() in DataMigrations.cs:line 27
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
at Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter.<>c__DisplayClass4_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
crit: Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
Application startup exception
As you can see, it's saying errors are being thrown in DataMigrations.cs. Which doesn't entirely make sense, since there has been zero changes in there for a significant amount of time. The area where the errors are being thrown is past the point where the database tables are created. So this would make sense that migrations are failing since the Tables don't exist.
So, to sum it up... Website won't load after newest publish. Tables aren't being created in Database as they should be. Connection strings are correct and no errors are appearing saying it's unable to connect.
One thing I do want to mention is that when looking in IIS Manager under Connection Strings, I noticed that there's nothing there anymore. Isn't this suppose to get auto-populated with whats in my AppSettings?
you can resolve this issue by repairing the iis server in programs and features.
please read this answer. it may help you
Specified argument was out of the range of valid values. Parameter name: site
After much debacle, it turns out when I publish Release mode the website wont work. But if I publish in Debug mode, everything is good to go. It's a temp fix, but it'll have to do for now. I'll have to look into why publishing release mode is broke.

SQLite attempt to write a readonly database error

I have a console application that populates a SQLite database. When the application runs by itself, I don't get any errors. If I run multiple instances of the application, where each application is in its own folder and each populates its own database I'll occasionally get the following exception:
System.Data.SQLite.SQLiteException (0x80004005): Attempt to write a read-only database
attempt to write a readonly database
at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt)
at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
at System.Data.SQLite.SQLiteDataReader.NextResult()
at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
I know the DB isn't read-only because it has already written data to that database. Also, the app continues on and will continue populating data to that database. I haven't reproduced the error when only a single instance of the application is running.
I've tried using the pragma to have both the journal and temp_store in memory instead of to a file in case there could be some contention across applications there, but I still get the error. I do always get the error in the same method, which is the first time an insert would happen for the connection. To give a general idea of what the application does, it loops over cases, gathers info about those cases (not from SQLite), then writes results to the SQLite database.
I don't know what else to try.
*edit
I am also using the PRAGMA journal_mode=MEMORY. When inserting data into the SQLite database, I first run a BEGIN statement, then a bunch of inserts before the END statement. The error occurs on the first insert.
It is a permissions issue.
Make sure that your web application that is hosted has add/write/create/delete access to the folder where the sqlite database resides.
For more details, refer this
Could also be that The database file is not supported by the MigrationAssembly.
The same exception is thrown when the EF tries to migrate on a file expected to be a SQLite database which is fi. a text file.

Cannot open database "ASPState" requested by the login. The login failed. Login failed for user 'xxxx'

I am working on one project which is in Asp.Net web form and Sql server. When I run application I get the error Unable to connect Sql Server Session Database and inner exception is Cannot open database ASPState requested by the login.
I did some google search to fix this issue. I don't have sa password so i cannot logged in as sa to assign privileges to ASPState database for the newly created User.
I don't see any ASPState database on Sql Server when i logged in. So i thought I might need to run aspnet reg exe on my machine. So i tried to run aspnetreg_regsql.exe but i got the following error.
An error occurred during the execution of the SQL file
'InstallCommon.sql'. The SQL error number is 5170 and the SqlException
message is: Cannot create file 'C:\Program Files\Microsoft SQL
Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\aspnetdb.mdf' because it
already exists. Change the file path or the file name, and retry the
operation.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Creating the aspnetdb database...
I am totally blank now to solve this issue, I will really appreciate your suggestion for this. This issue hold to publish on production.
Dont think that there is a simple answer to this with the permissions that you have, I think that what has happened is that the database HAS been created, but the user you are using does not have any access to it at all.
Without having an administrators credentials I dont think that you will be able to resolve the problem.
You can however work around it by re-creating the database with a different name:
aspnet_regsql -d[YourNewDBName] -RestOfYourParamaters
That should allow you to re-run the creation script, however there is no guarantee that you wont end up with the same issue on the newly created database.
You should issue the command DROP DATABASE aspnetdb and then re-run your script.
'InstallCommon.sql' surely ain't any database. It must be a script that installs a new Database, as the name suggests. Run the script, and then link the generated database

Developing with Azure Mobile Services in a local computer[.Net backend]

I'm developing a cloud service using Azure Mobile Services, and in order to test it quickly and debug it, I want to deploy it in my local computer. I select the project, hit F5, got it running in IIS express in my local PC. I execute the cliente against my local URI address of the IIS service and when I try to insert a value, this exception appears if I try to retrieve or insert a new object:
An exception of type 'System.ArgumentException' occurred in EntityFramework.SqlServer.dll but was not handled in user code
Additional information: The database name 'TR_MyTrip_Server_ExtraData_Service]_Persons_InsertUpdateDelete' is invalid. Database names must be of the form [<schema_name>.]<object_name>.
I debugged the Initialization of the controller and found out that mobile services deploys a LocalDb instance with this connection info on the DataBase property of the ServiceContext object:
Data Source=(localdb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MyTrip.Server.ExtraData.Service-20140731060708.mdf;Initial Catalog=aspnet-TestProject.Server.ExtraData.Service-20140731060708;Integrated Security=True;MultipleActiveResultSets=True
It is not able to find this DataBase if I try to connect with this connection string to the LocalDB via the SQL Management Studio
I'm able to access to the LocalDb instance with the SQL management studio running this command on CMD and retrieving the Connection for the LocalDB
SqlLocalDB.exe info v11.0
Eitherway, on the SQL Management Studio I'm not able to see any DataBase relating my controller of the Mobile Services. I searched on google and the only related link I found was this but is not working... Does anybody know what's happening?
Thank you so much
This is a problem when you have a project name with periods in it. Like TestProject.Server.ExtraData.Service.
To fix this, go into the web.config and edit the appsetting named "MS_MobileServiceName" taking out the periods. This is the value used as the SQL schema name for your mobile service tables in the database. It can't have periods or other special characters in it.
I generally try to make this the same as the name of the mobile service I'll deploy to, but it's not technically required.
For whatever reason, I couldn't get this working using the accepted answer. I assume this has something to do with the disclaimer in web.config which states:
After publishing to Mobile Services, these settings will be overridden by the values specified in the portal.
However, I did find another work around in the MobileServiceContext file where I replaced this line:
string schema = ServiceSettingsDictionary.GetSchemaName();
if (!string.IsNullOrEmpty(schema))
{
modelBuilder.HasDefaultSchema(schema);
}
with a simple string value modelBuilder.HasDefaultSchema('mySchema');
I imagine there's a way to influence the output of GetSchemaName() but, considering how much effort it took to resolve this problem, I am perfectly content with this solution for now.
If you've changed the MS_MobileServiceName in config to remove the periods, and you're still getting the error, you'll need to re-run the scaffolding for the Initial migration in the package manager console:
Add-Migration Initial -Force
From what I could see, the scaffolding generates an embedded .resx that still has your old schema name (DefaultSchema), and a snapshot (Target) that is referenced in the designer code. Just changing the DefaultSchema didn't solve the issue for me, but re-running the scaffolding did.
I also added Table annotations to my models, but I don't think that was the issue. And probably isn't ideal if your service is already live.

Why does this database connection fail when "Application Name=application" is in the connection string?

We're writing a multi-tenanted Silverlight application. The user logs in using Windows Forms authentication and we pull the connection string for that user from a table. The string was of the form:
Data Source=1.2.3.4; Initial Catalog=database; Persist Security Info=True; User ID=######; Password=##########
This was working fine. We then decided that setting the application name, for reasons outlined here would be a good idea:
Data Source=1.2.3.4; Initial Catalog=database; Application Name=application; Persist Security Info=True; User ID=######; Password=##########
However, now the connection isn't being made so we're getting errors. This is only failing on the deployed site. Running via Visual Studio is apparently unaffected. There have been no changes to the code that makes the connection. I'm willing to believe that there should be changes, but I haven't been able to work out what they should be.
The connection is being created like this:
public class OurDataContext : DataContext
{
public OurDataContext()
: base(SessionCache.OurConnectionString)
{
....
}
}
SessionCache.OurConnectionString is the string as read from the database.
UPDATE
The change to the connection string may be a red herring. We only get this failure on one web server (the one I don't have direct access to). Adding the property to the database referenced by another web server (that I do have access to) doesn't reproduce the problem. This is leading me to the conclusion that the error is somewhere else. However, I'm still no nearer to solving this.
The actual error is an exception:
An exception of type 'System.ServiceModel.DomainServices.Client.DomainOperationException' occurred and was caught.
------------------------------------------------------------------------------------------------------------------
01/31/2012 14:18:53
Type : System.ServiceModel.DomainServices.Client.DomainOperationException, System.ServiceModel.DomainServices.Client, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Message : Load operation failed for query 'GetUserSecurityConfig'. The remote server returned an error: NotFound.
Status : ServerError
ErrorCode : 0
Data : System.Collections.ListDictionaryInternal
Stack Trace : The stack trace is unavailable.
All the research I've done today on this returns some fairly basic things that shouldn't have changed:
System.ComponentModel.DataAnnotations, System.ServiceModel.DomainServices.EntityFramework, System.ServiceModel.DomainServices.Hosting and System.ServiceModel.DomainServices.Server not being copied to the \bin directory. I've checked and they are.
Errors connecting to the database server. I don't think this is the case as the forms authentication works. It is a different database on the server, but the credentials are the same.
The problem turned out to be due to the version of RIA Services installed on the server.
We'd recently changed the projects to include RIA Services via the NuGet package manager and this server already had RIA Services for VS2010 installed. When we sorted that out everything sprang back to life.
It's not clear why it took so long for this problem to manifest itself though.
We only get this failure on one web server (the one I don't have direct access to). Adding the property to the database referenced by another web server (that I do have access to) doesn't reproduce the problem.
Check webserver config and that the database is installed correctly.
looks like webserver config / db installion to me.

Categories

Resources