惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
I
InfoQ
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
Y
Y Combinator Blog
博客园_首页
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss
C
Check Point Blog
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Engineering at Meta
Engineering at Meta
B
Blog
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
F
Fortinet All Blogs
月光博客
月光博客
GbyAI
GbyAI

博客园 - KID

Core 1.0中publishOptions Include的bug EF Core 1.0 和 SQLServer 2008 分页的问题 net core 控制台中文乱码的解决方案 Evolution项目(1) asp.net5 Area的处理 asp.net5 操作Cookie 敏捷项目开源管理软件ScrumBasic(1) sharepoint 签入iframe出错的问题 wcf rest security sharepoint2013 错误2 关于html5缓存部分比较详细的说明 sps2013安装错误 sp2013版本区别 httpmodule sharepoint sharepoint session form timeout office2010 x64 Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 800 iphone 流媒体 ad 发光动画
敏捷项目开源管理软件ScrumBasic(2)- 多项目支持
KID · 2016-08-29 · via 博客园 - KID

1.加入Project对象模型

    public class Project
    {
        [Key]
        [MaxLength(32)]
        public string ID { get; set; }
        public string Name { get; set; }
        public int Order { get; set; }
        public ICollection<UserStory> Stories { get; set; }
        public ApplicationUser Creator { get; set; }
        public DateTime CreateTime { get; set; }
        public ApplicationUser Modifier { get; set; }
        public DateTime UpdateTime { get; set; }
    }

2.将Project关联到Story

public ICollection<UserStory> Stories { get; set; }

3.添加projectcontroller

遇到个bug:

 warning CS0169: The field 'UserStoryController.mystr' is never used 
 System.Data.SqlClient.SqlException: Column 'Project.ID' is not the same length or scale as referencing column 'UserStories.ProjectID' in foreign key 'FK_UserStories_Project_ProjectID'. Columns participating in a foreign key relationship must be defined wit h the same length and scale.
Could not create constraint or index. See previous errors.
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) 
    at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) 

这是由于系统生成的代码不能识别外键字段长度导致。

fix it

            migrationBuilder.AddColumn<string>(
                name: "ProjectID",
                table: "UserStories",
                maxLength:32,
                nullable: true);

启动。一切正常

 4. 下面来修改 Create New

删除 创建时间和更新时间,改由服务器赋值。

        public async Task<IActionResult> Create(UserStoryViewModel userStoryViewModel)
        {
            if (ModelState.IsValid)
            {
                //mapping   
                UserStory usNew = map.Map<UserStory>(userStoryViewModel);
                usNew.ID = Guid.NewGuid().ToString("N");
                usNew.StatusCode = "Unstarted";
                usNew.Creator = _userManager.FindByNameAsync(User.Identity.Name).Result;
                usNew.CreateTime = DateTime.Now;
                usNew.Order = _context.UserStories.Max(t => t.Order)+1;
                _context.UserStories.Add(usNew);
                await _context.SaveChangesAsync();
                return RedirectToAction("Index");
            }
            return View("OK");
        }

  details 和index删除 createtime

5.menu加入project

6.加入ViewStrories Action

<a asp-action="ViewStories" asp-route-id="@item.ID">View Stories</a> 

7.修改StoryController加入解析id  

完成。