Add New MVC5 Emplty Project Step By Step

1>Add New MVC5 Empty Project Give It Name and Add and Build Project

2>Right Click On Solution Add New Project>Select ClASS Library
Give Its Name As Project Name.Model
Click Ok And Delete Created Default Class1.cs File

3>Same As Add Repository
Right Click On Solution
Add New Project>Select ClASS Library
Give Its Name As Project Name.Repository
Clcik Ok And Delete Created Default Class1.cs File

4>Build ModelProject,Repository Project, Project And Solution

5>Right click on repository project and add new item
    Visual C# Items >Data >ADO.NET Entity Data Model
    Give Its Name As Model Project.edmx
    click add and select EF Designer from database
    click Next
   
    Click new Connection
    Change Datasource To Microsoft Sql Server and click ok
    give server name
    check use sql authentication radio button
    enter user name and password
    select database
    click test connection
    click ok if success
    select Yes, Include The sensitive data in the connection string and Click Next
select Entity Framework Version

Select Atleast One Table To Create Edmx Class
UnCheck First Check Box(Pluralize or singularize generated object names)
Click Finish

6>build 3 projects and solution
7> Right click on repository open folder
8>Open With NotePad (MyDemo.Repository.csproject) file
9>remove <dependentupon> tag from <None Include="MyDemoModel.tt"> tag

10> Reload All Select
11>Move Repository .tt file into Model Project
12>and remove from repository .tt file
13>add reference in repository of model.dll
14>build 3 projects
15>Open Modle .tt file append const string inputfile = @"repository Name"(const string inputFile =  @"..\MyDemo.Repository\MyDemo.Model.edmx";)
16>build 3 projects getting error for using MyDemo.Model; namspace in MyDemo.Context.cs file(Right Click MyDemo.Context.tt --Propertiese(set Custom Tool NameSpace(MyDemo.Model))
17>add Two new folder in Repository And Give Name ServiceContract(For Repository Interfaces Add) And Services(For Interface Classes Add)








    private MyDemoEntities context;
        public MST_Party_Repository(MyDemoEntities  _context)
        {
            this.context = _context;
        }

        private bool disposed = false;

        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    context.Dispose();
                }
            }
            this.disposed = true;
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }


Post a Comment

0 Comments