简体   繁体   English

实体框架数据库模型优先

[英]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.

相关问题 首先通过将类型作为参数传递来在Entity Framework DB中动态实例化Model对象 - Dynamically Instantiate Model object in Entity Framework DB first by passing type as parameter 如何基于Entity Framework代码优先模型自动生成.mdf db(如果不存在) - How to automatically generate .mdf db if it does not exist based on Entity Framework code-first model 实体框架4 DB-First依赖注入? - Entity Framework 4 DB-First Dependency Injection? 使用实体框架6的SQL Server TPT继承-数据库优先 - SQL Server TPT Inheritance with Entity Framework 6 - DB First MCV3实体框架4代码优先:将子对象添加到数据库 - MCV3 Entity Framework 4 Code First: Adding Sub Objects to the db 在Entity Framework DB First .Net应用程序中的何处放置CRUD功能 - Where to place CRUD functionality in Entity Framework DB First .Net Application 首先与Asp.Net成员资格提供程序一起使用实体框架模型 - Using Entity Framework Model First with Asp.Net Membership Provider 如何在Entity Framework 4.0模型的第一个设计器中添加文件流列? - How to add a filestream column in the Entity Framework 4.0 model first designer? 首先在实体框架模型中设计“热与否”样式数据库 - Designing “hot or not” style database in Entity Framework Model First 实体框架模型优先方法删除所有表数据 - Entity framework model first approach removes all table data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM