小编gri*_*n55的帖子

实体框架自动重命名多对多表而不进行任何更改

我在同一个项目工作了差不多一年半,今天当我想在数据库中添加一个更改(代码优先)时,所有突然的EF迁移都希望重命名很多存在于其中的多对多表.数据库今天.Theese表名称已经超过2年没有变化,我无法弄清楚为什么EF想要重命名它们.我已经检查了迁移所指向的实体文件,并且没有对可以解释此问题的文件进行更改.在这个项目中,我们使用数据注释,因此我们从未给多对多表赋予任何名称,我们只是让EF设置表的名称.任何帮助表示赞赏!

        RenameTable(name: "dbo.FilterLocation", newName: "LocationFilter");
        RenameTable(name: "dbo.FilterCluster", newName: "ClusterFilter");
        RenameTable(name: "dbo.ProfileFilter", newName: "FilterProfile");
        RenameTable(name: "dbo.HtmlTemplateFilterProfile", newName: "ProfileHtmlTemplateFilter");
        RenameTable(name: "dbo.HtmlTemplateProfile", newName: "ProfileHtmlTemplate");
        RenameTable(name: "dbo.CategoryHtmlTemplateFilter", newName: "HtmlTemplateFilterCategory");
        RenameTable(name: "dbo.HtmlTemplateCategory", newName: "CategoryHtmlTemplate");
        DropPrimaryKey("dbo.LocationFilter");
        DropPrimaryKey("dbo.ClusterFilter");
        DropPrimaryKey("dbo.FilterProfile");
        DropPrimaryKey("dbo.ProfileHtmlTemplateFilter");
        DropPrimaryKey("dbo.ProfileHtmlTemplate");
        DropPrimaryKey("dbo.HtmlTemplateFilterCategory");
        DropPrimaryKey("dbo.CategoryHtmlTemplate");
         AddPrimaryKey("dbo.LocationFilter", new[] { "Location_LocationId", "Filter_FilterId" });
        AddPrimaryKey("dbo.ClusterFilter", new[] { "Cluster_ClusterId", "Filter_FilterId" });
        AddPrimaryKey("dbo.FilterProfile", new[] { "Filter_FilterId", "Profile_ProfileId" });
        AddPrimaryKey("dbo.ProfileHtmlTemplateFilter", new[] { "Profile_ProfileId", "HtmlTemplateFilter_HtmlTemplateFilterId" });
        AddPrimaryKey("dbo.ProfileHtmlTemplate", new[] { "Profile_ProfileId", "HtmlTemplate_HtmlTemplateId" });
        AddPrimaryKey("dbo.HtmlTemplateFilterCategory", new[] { "HtmlTemplateFilter_HtmlTemplateFilterId", "Category_CategoryId" });
        AddPrimaryKey("dbo.CategoryHtmlTemplate", new[] { "Category_CategoryId", "HtmlTemplate_HtmlTemplateId" });
Run Code Online (Sandbox Code Playgroud)

*编辑我实际做的更改如下:

    AddColumn("dbo.HtmlAdField", …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework ef-code-first ef-migrations

6
推荐指数
1
解决办法
538
查看次数

只能选择一个复选框

我想一次只选择一个复选框.我的程序从文本文件中读取并根据文本文件中有多少"答案"创建复选框.

有谁知道代码有什么问题?

public partial class Form1 : Form

    {
        string temp = "questions.txt";

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            StreamReader sr = new StreamReader(temp);
            string line = "";
            List<string> enLista = new List<string>();
            while ((line = sr.ReadLine()) != null)
            {
                string[] myarray = line.Split('\r');
                enLista.Add(myarray[0]);


            }
            sr.Close();


            for (int i = 0; i < enLista.Count; i++)
            {
                if (enLista[i].Contains("?"))
                {
                    Label lbl = new Label();
                    lbl.Text = enLista[i].ToString();
                    lbl.AutoSize = true;
                    flowLayoutPanel1.Controls.Add(lbl);
                }
                else …
Run Code Online (Sandbox Code Playgroud)

c# checkbox winforms

2
推荐指数
2
解决办法
3万
查看次数