Firebird and ASP.NET MVC - asp.net-mvc

Have just started converting an existing job tracking system into an ASP.NET MVC application. I'm failing miserably at getting this thing off the ground. I'm getting this error
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.
With the following connection string
<add name="ApplicationServices"
connectionString="User ID=sysdba;Password=masterkey;Database=localhost:C:\\USINGFIREBIRD.FDB;"
providerName="FirebirdSql.Data.FirebirdClient" />
FirebirdClient has been added to windir\assembly using gcutil
This is probably a very dumb question, but does USINGFIREBIRD.FDB have to exist? Or will it be automatically created? Regardless, with the file created it does not work.
Edit:
Ok so in the end I was having so much trouble that I decided to start fresh.
First thing I discovered was that the .NET 4 assembly cache has moved to windows\Microsoft.NET\assembly. I saw that FirebirdClient was not in here so I had to figure out how to get it in there. I used Visual studio 2010 command prompt to add the assembly with GCUTIL.
Then I followed the information here
Then create a new asp.net mvc project, register your database in the server explorer, then add add an ado.net model class and have it auto generated from your database.
I'm writing this rather hastily as I'm about to leave work, hope it helps someone.

The file must exist and it must be a proper Firebird database, ie you can't just create an empty file named "USINGFIREBIRD.FDB". To create an Firebird database you can use the isql command line tool installed with Firebird.
BTW the error message says The server was not found or was not accessible - are you sure the Firebird service is running?

Your connection string part "Database=localhost:C:\\USINGFIREBIRD.FDB;" is wrong. If you database is a file you don't need the "localhost" just the db file path.
Here you can see valid connection strings for Firebird.

Related

ORA-12154: TNS:could not resolve the connect identifier specified (Oracle, ASP,Net, Dapper)

I can't find the exact issue I have on here or anywhere.
I have an ASP.Net MVC WebApi (MVC 5.1.0, Framework 4.5.1) project that uses Oracle.DataAccess. It runs on the local IIS server via a URL that's in my hosts file. It has a connection string connecting to an Oracle database. It works fine.
I have a 'normal' ASP.Net MVC (MVC 5.2.2, Framework 4.5.2) project that uses Oracle.ManagedDataAccess and Dapper. It runs on the local IIS server via a URL that's in my hosts file. It uses the SAME connection string (barring the providerName) to (attempt to) connect to an Oracle database. it does not work, throwing
ORA-12154: TNS:could not resolve the connect identifier specified
when I try to open the connection.
<add name="OurName" connectionString="Data Source=xxxxx_migration2;Persist Security Info=True;User ID=OurUserName;Password=thepassword;Enlist=False;Min Pool Size=10;Connection Lifetime=120;Connection Timeout=30;Incr Pool Size=5;Decr Pool Size=2;" providerName="Oracle.ManagedDataAccess.Client"/>
TNSNames.ORA is fine [as you'd reckon given that the exact same connection string works in the other project], there are no brackets in the project file paths (a very obscure issue I found in my researches), ORACLE_HOME is pathed... I am stumped.
I know Dapper extends the connection object - does it have any really funky weird requirements that might be causing this?
EDIT: If I switch the 'normal' ASP.Net MVC (and connection string providerName parameter) to Oracle.DataAccess, and don't use Dapper I can connect.
In the end, I needed to make more config file changes than I thought, in order to make Oracle.ManagedDataAccess work (Dapper was not an issue).
see this blog article
and the accepted answer here
It's a little bit annoying, and a change from the past situation to have to manually specify the location of TNSNAMES.ORA in the config file - but hey, it's a config file after all.
In my case, in Web.config file, oracle.manageddataaccess.client -> dataSources tag, alias name was wrong. Once changed, it worked.

Trouble deploying EF CodeFirst to server

I have a CodeFirst web application that originally used LocalDb. I changed the connection string to:
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.\SqlExpress;Initial Catalog=aspnet-BatchFindings;Integrated Security=True" />
And I created the appropriate database using Server explorer.
I am using WebDeploy to publish to a Windows Server 2012 instance running IIS8.
After publishing, I was unable to use the application; it did not have permissions for the database. I then changed the identity to a user account, and now I do not get database errors. Except the application does not appear to save any data to the database. I am at a complete loss - any help is appreciated!
Recap:
Entity Framework, Code First
Web Deploy to IIS 8
Custom Application Pool, identity set to a user account
Data not being stored in database.
EDIT: I would love to be able to simply use Web Deploy and have it use its own database (so it does not get test data from mine) but this is just so frustrating! I am publishing, the connection string should work, not sure where I am going wrong.
Stupid question but are you calling DbContext SaveChanges() method after data manipulation - data saving works when testing?
Also you can use different web.config files when testing (Debug) and deploying (Release version).
So I inadvertently figured out the reason why it was not saving. For some reason in my test environment everything worked, but when it was pushed out, I needed to add the following line:
db.Entry(obj).State = System.Data.EntityState.Added;
I checked out the tutorial, which seemed to work until it went into that Grant.sql file. There is no option in Visual Studio to connect.
What I ended up doing in that case to get the database working was set my Application Pool to run under a user identity I created for this purpose, while setting Load User Profile to True. You can also run as LocalSystem (as long as you create the following folder: C:\Windows\SysWOW64\config\systemprofile\Desktop - this tricks the system into thinking the LocalSystem account is interactive).

How do I connect to a code-first created localdb database using database explorer?

I have a database in an MVC 4 project that has so far been entirely managed via Code First and Migrations. I now want to go in and change some of the data by hand. How can I connect to the localdb instance using Database Explorer within Visual Studio 2012? The connection string is as follows:
Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-mydb-20120830192823;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-mydb-20120830192823.mdf
I have an App_Data folder in my project, but the .mdf named in the connection string is not in there.
I have tried connecting to '(LocalDb)', 'LocalDb', '.SQLEXPRESS' and various other things in the Add Connection dialog, but nothing seems to work.
Duh, it was '.\SQLEXPRESS' I needed to connect to.

LINQ to SQL cannot connect to database, but the connection string is good

I've deployed a MVC site and it's database to a web hosting provider. The default ASPNET tables and the applications custom ones share the same database. There are two connection strings in the web config, one for ApplicationServices and one for my LINQ to SQL dbml. As they share the same database then I use a identical connection string for both.
The application services functions seem to work as I can log into the site. However the return controller throws an exception because it's trying to use my data context this time. Identical connection string and yet it gives me the error:
A network-related or instance-specific
error occurred while establishing a
connection to SQL Server. The server
was not found or was not accessible.
Verify that the instance name is
correct and that SQL Server is
configured to allow remote
connections. (provider: Named Pipes
Provider, error: 40 - Could not open a
connection to SQL Server)
This of course all works properly on my local machine. I would very much appriciate any suggestions as to why LINQ to SQL can't connect with a valid connection string.
The LINQ to SQL dbml file is inside a class library and the startup ASP.NET web project consumes this library as it's data layer. LINQ to SQL was reading it's connection string from the app.config of the class library when run through visual studio. When publishing the web project the dependent data library gets included but not it's app.config. I understand now that the fully qualified connection strings need to be manually copied into the web.config of the primary project where they override the defaults for the assembly. The problem I was facing was that with the absence of an app.config and no connection strings in the web.config, at least not fully qualified ones, the library was falling back to it's development defaults.

Web Site Administration Tool Not Working with ASP.NET MVC

I'm just starting with ASP.NET MVC and I was trying the Authentication with this new architecture.
So, I started following a tutorial in the official site and, while I was trying to add some users through the Web Site Administration Tool, I found this error:
There is a problem with your selected data store. This can be caused by
an invalid server name or credentials, or by insufficient permission.
It can also be caused by the role manager feature not being enabled.
Click the button below to be redirected to a page where you can choose
a new data store.
The following message may help in diagnosing the problem: Could not load type
'MyMvcApp.MvcApplication'.
Now, the only thing I changed in the web.config was the connection string and, I'm sure the connection string is not the problem (is the same I'm using in other project).
EDIT: Here is the connection string: "Data Source=myMachine\SqlExpress;Initial Catalog=TestDB;User ID=TestUser;Password=123456"
I tried several things and googled a lot, but nothing worked.
So, any ideas? as I said, I did not change anything in the web.config besides the connection string.
Thanks in advance,
Found the problem: I just need to COMPILE the solution BEFORE starting the WSAT.
Thanks to everyone for your answers.
Well, like the message says, this feature requires real management enabled, and the default MVC web site template has this disabled. Go into Web.config and change:
<roleManager enabled="false">
to
<roleManager enabled="true">
One other thing to check: Make sure that when you create the SQL Membership Provider metadata you connect as a user who will be useful at runtime. In other words, if you connect as sa, then the metadata will be in the dbo schema. But if you connect as yourself, then the metadata will be in your schema, which isn't necessarily useful to other applications. You should run SQL Server Management Studio in order to verify in which schema the metadata is placed.

Resources