Connection string between IIS and SQL server

后端 未结 4 724
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-21 14:44

I\'m confused by the connection string in the Web.config file of project with Entity Framework Web API. There are a lot of variants I tried, but none of them was helping me out.

4条回答
  •  一向
    一向 (楼主)
    2021-01-21 15:01

    This tutorial how to setup SQL Server 2008 for an ASP.net website on IIS 7.0 brought me close to the solution.

    Basically, what you need to do is

    1. Install SQL server.
    2. Allow TCP/IP connections to the SQL server.
    3. Attach your database.
    4. Create a login. I'm using SQL Authentication.
    5. Assign the user permissions to your database.
    6. Configure your database connection string.

    Changing the name of my connection string helped me establish the connection finally.

    
           
    
    

    The context model required this name.

    public class MyProjectContext : DbContext
    {
    
        public MyProjectContext() : base("name=MyProjectContext")
        {
        }
    
        public DbSet Model1 { get; set; }
        public DbSet Model2 { get; set; }
    }
    

提交回复
热议问题