I have created an ASP.NET Core web app using the MVC template, added my model class, added a corresponding controller, and ran add-migration "initialsetup" followed by update-database at the package manager console.
However, I have ended up with 2 local databases:
Why is this?
I had some difficulty getting here; e.g. for the controller name, I went for ConsumerModelController (singular) despite its automatic suggestion for ConsumerModelsController (plural) which ended up failing, but when I then went for the default suggested plural name, it worked...
Try deleting both databases and execute Update-Database again, It should create one database? Also try renaming your database name into something easier to be compared.
Related
Right, so..I think I'm confused!!
I have a few ASP.NET MVC 5 sites running using ASP.NET Identity 2.1 and everything is great. I am creating a new MVC 6 site and I would like the users to use there existing credentials that they use for other systems. I have already tried the below:
Migrating the ASP.NET identity 2 database to 3 (says it cannot as the tables already exist, I thought it would migrate the users in all honesty)
Tried getting MVC 6 to work with ASP.NET Identity 2.1 and failed miserably
I am just wondering what my options are since the documentation is not great on the new version, I get that there are DDL changes in the DB but I was kind of hoping there would be a way for my MVC 5 websites to carry on going as is with the .NET Identity 3 database being backwards compatible with 2.1.
My other option is to upgrade the MVC 5 apps to use Identity 3 which in turn I believe means updating them to MVC 6, which is something I don't really have the resources for, or to have a totally new Identity database (which seems the least fuss option).
Any opinions would be helpful, no doubt I have missed out some detail so happy to fill in the blanks should anyone have any further questions about the setup.
I was doing the same thing, its a good deal of effort - and you will have to run db migrations, but first
The new ASP Identity V3 Tables & Migration
The new ASP Identity V3 Fields
Configuring the tables
In Startup.cs and change services.AddIdentity
services.AddIdentity<ApplicationUser, IdentityRole<int>>()
.AddEntityFrameworkStores<ApplicationDbContext, int>()
.AddDefaultTokenProviders();
In ApplicationContext.cs and change the class to the following signature.
public class ApplicationDbContext : IdentityDbContext<ApplicationUser, IdentityRole<int>, int>
In ApplicationUser.cs and change the class to the following signature.
`public class ApplicationUser : IdentityUser<int> {...}`
Given all the changes I found it easier to delete everything in the
migrations folder (except the migrations). Go to command prompt on
the directory of the project and type/add a migration like so dotnet
ef migrations add MyDatabaseHere -o Data\Migrations. (-o Option is to specify target folder and not root folder)
for any issues with migration I would simply drop the database and just deploy again.
or you can automate with this I have not tried this
I got two migration scripts from EF, I was not sure why... but for more references from github links 1 & 2
Implement IdentityServer3, it can hook directly into your existing ASP.Net Identity EF DB. Then use the other sites as oAuth clients, being MVC 5 and/or MVC 6 it wont matter because all they will be doing is passing secure tokens back and forth between your IdentityServer3 site.
You can use identity 2 in Asp.Net Core and mantain the passwordhash in the database.Just add this code in startup.cs
services.Configure<PasswordHasherOptions>(options => {
options.CompatibilityMode = PasswordHasherCompatibilityMode.IdentityV2;
});
I am trying to move a cakePHP project I completed a few months ago from a server (a friend's server) to my own web server.
I have set up a database and changed the database config file to match my database/login credentials.
when I navigate to http://babbage.cs.missouri.edu/~jam2z9/muve/index.php you see it looks as if it is a brand new project. When I go to just /muve instead of index.php it says I'm missing a ~jam2z9Controller file but I don't see any files from the old server that are like this to edit and change to ~jam2z9.
I feel like this should be a very simple transition once I hook up the database credentials but I'm just confused as to what my issue is?
All of the database tables in my new database are blank as I just imported the .sql file into phpMyAdmin. It all seems to be connecting fine but it will not go to the home page just the aforementioned generic cakephp screen?
In your bootstrap.php add the following line:
Configure::write('App.base', '/~jam2z9/');
This is because as far as Cake sees it you are hosting it in a sub-sub directory.
Edit: There are more details about not being able to use mod_rewrite here
I would like to accesss the sitecore DB and items from console application like
Sitecore.Data.Database db = Sitecore.Context.Database
or
Sitecore.Data.Database db = Sitecore.Data.Database.GetDatabase("master")
how do I configure and setup my console application to access the DB as above?
Thanks Everyone for the suggestion, I am really interested in config changes, I used webservice, but it has very limited methods. For example, if I would like create an Item with the template and insert the item with prepopulated value, there is no such option. The reason I am looking for the console apporach is I would like to import the contents from XML or excel sheet and push those to the sitecore tree, eventually use the scheduled task to run the console app periodically. I do not want to copy the entire web.config and app_config. If anyone has already done this, could you please post your steps and necessary config changes?
You have two options I think:
1) Import the Sitecore bits of a website's web.config into your console application's app.config, so that the Sitecore API "just works"
I'm sure I read a blog post about this, but I can't find the reference right now. (I will have another look) But I think the simple but long winded approach is to copy all of the <sitecore/> element and all the separate files it references. I'm fairly sure you can whittle this down to a subset of the config required for data access with a bit of thinking.
2) Don't use the Sitecore API directly, connect to a web service that exposes access to it remotely.
There are a few of these that already exist. Sitecore itself exposes one, Sitecore Rocks has one, and Hedgehog TDS has one too. And you can always write your own (since any web service running inside the Sitecore ASP.Net app can make database calls and report values back and forth - just remember to consider security if this web service might end up exposed externally for any reason)
John West links to some relevant stuff here:
http://www.sitecore.net/Learn/Blogs/Technical-Blogs/John-West-Sitecore-Blog/Posts/2013/09/Getting-Data-Out-of-the-Sitecore-ASPNET-CMS.aspx
-- Edited to add --
I've not found the blog post I remember. But I came across this SO thread:
Accessing Sitecore API from a CLI tool
which refers to this blog post:
http://www.experimentsincode.com/?p=232
which I think gives the info you'll need for option 1.
(And it reminds me that, of course, when you copy the config stuff you have to copy the Sitecore binaries into your app's folder as well)
I would just like to expand on #JermDavis' post and note that Sitecore isn't a big fan of being accessed when not in a web application. However, if you still want to do this, you will need to make sure that you have all of the necessary configuration settings from the web.config and App_Config of your site in your console application's app.config file.
Moreover, you will never be able to call Sitecore.Context in a console application, as the Sitecore Context sits on top of the HttpContext which means that it must be an application and have a valid request for you to use it. What you are looking for is something more along the lines of Sitecore.Configuration.Factory.GetDatabase("master").
Good luck and happy coding :)
This sounds like a job for the Sitecore Item Web API. I use the Sitecore Item Web API whenever I need to access Sitecore data from the master database outside the context of the Content Management server or outside of the context of the Sitecore application. The Web API definitely does not allow you to do everything that the standard Sitecore API does but it can act as a good base and I now extend upon the Web API instead of writing my own custom web services whenever possible.
Thanks to JemDavis's advise.
After I copied the configuration and made changes to config section to get rid of conflicts. I copied almost all of Sitrecore, analytics and lucene dlls, it worked great.
Only thing you have to remember is, copy the app_config folder to the same location where your dlls are.
Thanks again JemDavis....
I'm still new to Liferay and using Liferay 6.2
what i'm doing:
I am trying to add a document manually into my database using insert statement.
I inserted into dlfileentry, dlfileversion and AssertEntry.
Also, i created a folder with the valid name and file.
The issue:
upon entering the Documents and Media portlet, i can see the document name there but when i click on checkout, it will prompt a error saying that Documents and Media is temporarily unavailable. however i am still able to download the valid document.
Am i doing something wrong? Personally, i feel that i am missing one more table for the database but i'm not sure .
Thanks!
Yes, you're doing something wrong: You should never write to Liferay's database with SQL, as there might be more data required than what's directly visible to you. Obviously, you're running into exactly such an issue.
Liferay has an API which you can use locally, from within the same application server, or remotely as JSON or SOAP service. You should exclusively use this for write access to the database.
Alternatively, you might consider WebDAV access to your document repository as the way to add more documents to the document library.
I have a problem with the binding of the sessionfactory and working with two silverlight projects and two sessionfactories.
I have one "main-project" which works against one database that need to access a second database trough a wcf-service-call. The second project (backend) has its own sessionfactory for accessing the database.
My problem is that I bind the sessionfactory to the HttpContext with ManagedWebSessionContext.Bind(HttpContext.Current, _sessionFactory.OpenSession()) with all my regular service-calls but when i call the service on the backend-project I want to use the backend-sessionfactory. When I make this call i get the sessionfactory for the main-project instead of the on for the backend-project. How can i do that?
This was not a problem when we deployed to our testserver so it's seems to be a problem only if I run the projects in the same environment as I do in debug.