I am trying to build a basic web app, and I want to connect it to a database. I have a heroku account so I started trying to get it hooked up to a Postgres DB and ran into issues around SSL and external connections. I tried to update my code and realized that I was missing the references to SQL so tried adding Entity Framework through the package manager.
It goes through the checking compatibility and then tells me
Could not add Entity Framework
I am new to this so not sure what I can provide to help get the answer.
Am I just going about it wrong, is EF not what I need to make a simple DB connection?
Related
I can't get the example from this link to work:
ASP.NET Core Application to New Database
I've copy pasted everything I could on the page but every time I browse the page, it says:
"Cannot open database "EFGetStarted.AspNetCore.NewDb" requested by the login. The login failed."
I am using an Admin account. I tried creating an SQL Server login with username and Password, but still error.
ADDITIONAL INFO:
I've tried manually creating the database and I can connect on it using the same connection string, but I want the migrations to run and automatically create the database.
The documentation you are following is a bit out of date. This is a major problem with the path .NET Core and associated frameworks have taken to final delivery. The migrations creation examples in the documentation you are following no longer work. You should use the examples found at:
https://docs.asp.net/en/latest/data/ef-mvc/migrations.html
In the main ASP .Net Core documentation site.
I have previously used System.Data.Sqlite 1.0.85 with EF5 in VS2010 and it worked well and I came to really like the designer. On my new machine, I've switched to VS2013 Community and tried to get Sqlite 1.0.94 and EF6 running, but it's such a hassle and I'm starting to get really frustrated. I can't seem to get it running on my old project, which I need to work on, but only on a fresh one. Tried copying the old stuff, but it just stops working again. From what I've read, I'm not the only one having these issues.
I can connect to the database in the server explorer, but the connection won't show up in the Entity Data Model wizard. It did run once on a fresh project, but since I keep running into trouble, I'd rather switch to something else that actually works.
So my question is, what alternatives are there? It's for a small business application. Would LocalDb be an alternative? Are there any other good databases/providers (free ones) that work well with EF and have designer support in VS2013?
Thanks for any feedback!
LocalDb can be used in the dev environment and works really well. But it might be too limiting for production use depending upon your requirements. Another option would be to use SQL Server Express. But this again might have limitations in a prod environment. The following link gives you an overview of the features of different versions of SQL Server:
SQL Server Editions
Another option would be to go for something like PostgresSQL or MySQL but I haven't used them, so can't say much about them.
I have a web application created using Entity Framework. The site was originally created using SQL Server CE, but I have since moved everything over to SQL Server. When I switched to SQL Server, I removed all references to SQL Server CE from my project, however when I try to add a new migration I am getting this error:
Schema specified is not valid.
Errors: (0,0) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0'. Make sure the provider is registered in the 'entityFramework' section of the application config file.
I've discovered that if I create a new database and point my development system there everything works, but when I then point it back to one of my existing customers databases I get the error. It seems that the reference to SqlServerCe.4.0 is somehow embedded in the _MigrationHistory table.
Is it possible to manually rebuild _MigrationHistory for my existing databases? Or is there a better solution?
I'm developing a WPF that generates an SQLCE DB at runtime and fills it.
Everything runs fine in debug, but when I distribute an app to a 64bit Windows 7 machine I get a
Access to the database file is not allowed
error because the system cannot create the .sdf file. I think it's a permission issue but I don't know what I can do to avoid this problem, is there anything to do in setup project or a flag to give to Entity Framework for forcing DB creation?
Create the sdf file in a location where the user has write access.
I guess I should have thought of this before I started my project but I have successfully built and tested a mini application using the code-first approach and I am ready to deploy it to a production web server.
I have moved the folder to my staging server and everything works well. I am just curious if there is a suggested deployment strategy?
If I make a change to the application I don't want to lose all the data if the application is restarted.
Should I just generate the DB scripts from the code-first project and then move it to my server that way?
Any tips and guide links would be useful.
Thanks.
Actually database initializer is only for development. Deploying such code to production is the best way to get some troubles. Code-first currently doesn't have any approach for database evolution so you must manually build change scripts to your database after new version. The easiest approach is using Database tools in VS Studio 2010 Premium and Ultimate. If you will have a database with the old schema and a database with the new schema and VS will prepare change script for you.
Here are the steps I follow.
Comment out any Initialization strategy I'm using.
Generate the database scripts for schema + data for all the tables EXCEPT the EdmMetadata table and run them on the web server. (Of course, if it's a production server, BE CAREFUL about this step. In my case, during development, the data in production and development are identical.)
Commit my solution to subversion which then triggers TeamCity to build, test, and deploy to the web server (of course, you will have your own method for this step, but somehow deploy the website to the web server).
You're all done!
The Initializer and the EdmMetadata tables are needed for development only.