My Database Team created a database called XMEN
.
I need to use that specific database with my project. I have full admin rights on that database but not on the server (they won't give it to me).
CREATE DATABASE permission denied in database 'master'.
When I run my project, I get the error above because I don't have permission to create a database. How can I use entity frameworks to specify which database to use? I want Entity Framework to manage everything else (tables, relationships, etc)
------------- UPDATED 9/17/2020 - 9:12 AM EST
public class XmenContext : DbContext
{
//public XmenContext(DbContextOptions<XmenContext> options)
// : base(options)
//{
//}
public XmenContext() : base("XmenDatabase")
{
}
Now I get an error saying cannot convert from String to Microsoft.EntityFrameworkCore.DbContextOptions
I clicked the link in your answer.
You should add the database name to the connection string in your configuration file. If you need some help you can view here :
https://docs.microsoft.com/en-us/ef/ef6/fundamentals/configuring/connection-strings
If you are having trouble add your connection string to the question (without sensitive information) and I will try to help.
Good luck !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.