Specify an SQL username other than dbo in Code First Entity Framework ( C# ASP.NET MVC 3 )

前端 未结 5 1752
梦毁少年i
梦毁少年i 2020-12-31 06:41

I\'m trying to connect to an SQL Server 2008 database in a shared hosting environment from C# from within an ASP.NET MVC 3 application connecting via EF (code first).

<
5条回答
  •  长情又很酷
    2020-12-31 07:08

    With EF6, you can now do this.

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.HasDefaultSchema("logs");  //set default schema
            modelBuilder.Configurations.Add(new LogMap());
            ...
        }
    

提交回复
热议问题