[英]Entity Framework DB Model First
I've created a fresh ASP.NET Web Forms model, with authentication pre built. 我已经创建了一个新的ASP.NET Web窗体模型,并预先建立了身份验证。 I've then run through the following link
然后,我浏览了以下链接
http://msdn.microsoft.com/en-us/data/jj206878 http://msdn.microsoft.com/en-us/data/jj206878
and created an entity framework from my exisiting database. 并从我现有的数据库中创建了一个实体框架。
Ok, so far so good, however, when i fire up the project and click Register, the user created is still being inserted into a local db in the App_Data folder. 好的,到目前为止,很好,但是,当我启动该项目并单击“注册”时,创建的用户仍将插入到App_Data文件夹中的本地db中。
Why is this, and how can I ensure that all new users are pooled / created in my own database? 为什么会这样,如何确保所有新用户都在我自己的数据库中池化/创建?
Change you Default Connection String at Web.config/App.config with credentials of your own database. 使用您自己的数据库的凭据在Web.config / App.config处更改默认连接字符串 。
Hope following link will help you: 希望以下链接能为您提供帮助:
http://hgminerva.wordpress.com/2013/09/21/how-to-create-the-asp-net-membership-tables-in-your-own-database/ http://hgminerva.wordpress.com/2013/09/21/how-to-create-the-asp-net-membership-tables-in-your-own-database/
Probably because your DbContext is using built-in connection string. 可能是因为您的DbContext使用内置的连接字符串。 You can specify which connectionstring from your web.config to use when you initialize it in constructor like so.
您可以像这样从构造函数中初始化web.config时指定使用哪个连接字符串。
public class MainDataContext : DbContext
{
public MainDataContext() : base("Name=NameOfConnectionString") { }
// public DbSet ...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.