简体   繁体   English

实体框架更改了我的默认数据库名称

[英]Entity Framework changes my default database name

I'm using Entity Framework 6 and it changes my defualt database name for examle BLOODGROUP_08bb0dde1a5b4193828358a79cb01315. 我正在使用Entity Framework 6,它会更改示例BLOODGROUP_08bb0dde1a5b4193828358a79cb01315的默认数据库名称。

My context class is: 我的上下文类是:

  public BloodGroupContext()
        : base("BloodGroup")
    {

    }

and my connection string is: 而我的连接字符串是:

 <add name="BloodGroup" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\BloodGroup.mdf;Integrated Security=True"
  providerName="System.Data.SqlClient" />

I searched for the answer but I couldn't find anything. 我搜索了答案,但找不到任何东西。 I currently run microsoft sql server 2012 我目前正在运行Microsoft SQL Server 2012

What's the initial catalog of your connection string? 您的连接字符串的初始目录是什么? This will set your database name. 这将设置您的数据库名称。 Try setting this to your existing database name. 尝试将此设置为您现有的数据库名称。

Use: 采用:

  public BloodGroupContext()
        : base("name=BloodGroup")
    {

    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM