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

推荐订阅源

博客园 - Franky
J
Java Code Geeks
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
美团技术团队
L
LangChain Blog
WordPress大学
WordPress大学
A
About on SuperTechFans
Martin Fowler
Martin Fowler
月光博客
月光博客
Y
Y Combinator Blog
U
Unit 42
D
Docker
Recent Announcements
Recent Announcements
Hugging Face - Blog
Hugging Face - Blog
B
Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

博客园 - 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  

完成。