connection-string

No context type was found in the assembly

纵饮孤独 提交于 2019-11-30 07:53:54
I'm using .NET 4.0, MVC3, and EF5 with code first. My solution is split up into three projects, with the dependencies as indicated: Project.Web -> Project.BLL -> Project.DAL The Project.DAL layer contains my entity framework data context class and all my entities, but my startup project is Project.Web, so it contains my Web.config, connection strings, and the actual SQL compact database. I'm trying to enable migrations so I can add a new table to my EF model without wiping the existing data. However, when I run "Enable-Migrations", I get No context type was found in the assembly 'Project.Web'.

How do I set an ADO.NET Entity Framework connection string via the Windows Azure (Preview) Management Portal?

江枫思渺然 提交于 2019-11-30 07:20:48
问题 In the Windows Azure (Preview) Management Portal you can change the configuration options for web sites (see http://www.windowsazure.com/en-us/manage/services/web-sites/how-to-configure-websites/#howtochangeconfig). I currently set the connection string for my ADO.NET Entity Framework connection via Web.Release.Config, but I want to set it via the Management Portal, but no matter what I use, I always end up with the following error: The specified named connection is either not found in the

Can I Add ConnectionStrings to the ConnectionStringCollection at Runtime?

旧时模样 提交于 2019-11-30 07:07:22
问题 Is there a way where I can add a connection string to the ConnectionStringCollection returned by the ConfigurationManager at runtime in an Asp.Net application? I have tried the following but am told that the configuration file is readonly. ConfigurationManager.ConnectionStrings.Add(new ConnectionStringSettings(params)); Is there another way to do this at runtime? I know at design time I can add a connection string to the web.config; however, I'm looking to add something to that collection at

Using a separate file to maintain the connection string for entity framework

杀马特。学长 韩版系。学妹 提交于 2019-11-30 05:28:34
问题 I have my connection string currently in my web.config file. Is it possible to place it in a separate file and point entity framework to it. 回答1: I found the answer here Separate ConnectionStrings and mailSettings from web.config? Possible?: <configuration> <connectionStrings configSource="connections.config"/> </configuration> With file connections.config containing <connectionStrings> <add name="name" connectionString="conn_string" providerName="System.Data.SqlClient" /> <add name="name2"

What is the correct format for Running Entity Framework migrate.exe tool without a Web/App.config?

折月煮酒 提交于 2019-11-30 04:43:15
We recently switched to Entity Framework data migrations and I am working on some build automation scripts for our MVC app. I can successfully run the migrations from our build server using the migrate.exe tool in 4.3 if I have a Web.config to point it at. The command looks something like: ProjectName\packages\EntityFramework.4.3.1\tools\migrate.exe MyAssembly /startupdirectory:ProjectName\bin\Debug /startupconfigurationfile:ProjectName\Web.config /verbose However, for various reasons I would like to avoid using the Web.config and just pass in the correct connection string at the time of the

SQL integrated security using computer name instead of user name

♀尐吖头ヾ 提交于 2019-11-30 03:44:34
I am trying to an SQL Express instance on the same network, authenticating with my domain user. It works just fine with Windows Authentication in SSMS. I verified that I can use the MyDB database, including editing tables. However, when I try the following connection string: Server=ipaddress\SQLExpress; Database=MyDB; Integrated Security=SSPI; I get back an error: Cannot open database "MyDB" requested by the login. The login failed. Login failed for user 'ROMANIA\MONSTER2$' The problem is that MONSTER2 is the name of my computer, not my username. (ROMANIA is the domain.) What am I doing wrong?

How to add entity framework 6 provider in code?

六月ゝ 毕业季﹏ 提交于 2019-11-30 03:17:35
问题 I use Entity Framework 6 in a C# application and it works perfectly. When creating the Model, the app.config is generated with all the necessary configuration. Now I don't like having stuff in the app.config, so I use the connection string builder. I succeeded in removing everything out of the app.config file except of this: <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> <providers> <provider invariantName="System

Wait! which config file? (Entity Framework Connection String)

╄→尐↘猪︶ㄣ 提交于 2019-11-30 03:16:43
So, I created my entity model in a separate class library. I had to add the connection string to the app.config file of that class library. Then I added a ref for that project in my web application. I added the same connection string in the web.config of my web application thinking this is where Entity Framework will be reading the connection string from. Everything was fine up until I deployed my web app. When I deployed I change the connection string in the web.config (not app.config of the class library) and I started getting errors. After doing some research I found out that the connection

problem with [SqlException (0x80131904): Invalid object name 'dbo.TableName'.]

一曲冷凌霜 提交于 2019-11-29 23:22:42
问题 I was looking in google and stackoverflow and i did not find the answer, how can I connect to my database table through that connection string in VS 2010 ? <add name="ArticleDBContext" connectionString="Data Source=mssql3.webio.pl,2401;Initial Catalog=db_name;Persist Security Info=True;User ID=db_user;Password=passwd;Pooling=False" providerName="System.Data.SqlClient" /> I always get error: problem with [SqlException (0x80131904): Invalid object name 'dbo.TableName'.] I know that 'dbo' is

Entity Framework connection string not from config

无人久伴 提交于 2019-11-29 21:47:50
public class Context : DbContext { public Context(string connString) : base(connString) { Database.SetInitializer(new MyContextInitializer()); } //... Need to pass a connection string to the context constructor. How should the string look like, for example, for SQL Compact? Tried this, but no success: Context db = new Context("Provider=System.Data.SqlServerCe.4.0;Data Source=D:\\Context.sdf"); Edit: If I try this string: "Data Source=D:\\Context.sdf" System.Data.ProviderIncompatibleException was unhandled Message=An error occurred while getting provider information from the database. This can